BUI logoDWC logoBBjWebManager::toggleClass

Description

In BBj 24.00 and higher, this method toggles a class name on a selected element on the web page.

Note:

In BBj 22.03 and higher, BBjWebManager is an alias for BBjBuiManager.

Syntax

Return Value Method
boolean toggleClass(String className)
boolean toggleClass(String className, String selector)

Parameters

Parameter Description
className Specifies a CSS class name to be toggled on the control.
selector By default, BBjWebManager::toggleClass applies to the document element on the web page. If a selector is specified, it selects a descendant element within the document. If a specified selector doesn't return any elements, the default document element is used.

Return Value

If the specified className was set on the selected element, this method removes it and returns false (0). If the specified className was not set on the selected element, this method adds it and returns true (1).

Remarks

This corresponds to Element::classList::toggle.

Example

rem ' BBjWebManager::toggleClass

sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()

browser! = bbjapi().getWebManager()

title$ = "BBjControl::toggleClass"
window! = sysgui!.addWindow(25,25,350,350,title$,$00090083$)
window!.setCallback(window!.ON_CLOSE,"eoj")

text$ = "The quick brown fox jumps over the lazy dog."
text! = window!.addStaticText(100,25,25,300,25,text$)
text!.setName("Sample")

window!.addStaticText(101,25,75,50,25,"Class:",$8000$)
class! = window!.addEditBox(102,100,75,225,25,"xyzzy",$$)

addClass! = window!.addButton(103,100,125,225,25,"addClass")
addClass!.setCallback(addClass!.ON_BUTTON_PUSH,"addClass")

removeClass! = window!.addButton(104,100,175,225,25,"removeClass")
removeClass!.setCallback(removeClass!.ON_BUTTON_PUSH,"removeClass")

toggleClass! = window!.addButton(2,100,225,225,25,"toggleClass")
toggleClass!.setCallback(toggleClass!.ON_BUTTON_PUSH,"toggleClass")

getClassList! = window!.addButton(1,100,275,225,25,"getClassList")
getClassList!.setCallback(getClassList!.ON_BUTTON_PUSH,"getClassList")

process_events
eoj:
  release

addClass:
  browser!.addClass(class!.getText(),".Sample",err=*next); return
  i = msgbox(errmes(-1),0,"BBjWebManager::addClass")
return

removeClass:
  browser!.removeClass(class!.getText(),".Sample",err=*next); return
  i = msgbox(errmes(-1),0,"BBjWebManager::removeClass")
return

toggleClass:
   class$ = class!.getText()
   toggle! = browser!.toggleClass(class$,".Sample",err=oops)
   classList! = browser!.getClassList(".Sample",err=oops)
   title$ = "toggleClass "+class$+" = "+Boolean.toString(toggle!)
   i = msgbox("getClassList = "+str(classList!),0,title$)
return
oops:
  i = msgbox(errmes(-1),0,"BBjWebManager::toggleClass")
return

getClassList:
   classList! = browser!.getClassList(".Sample",err=nope)
   i = msgbox(str(classList!),0,"getClassList()")
   return
nope:
  i = msgbox(errmes(-1),0,"BBjWebManager::getClassList")
return

ClosedVersion History

  • BBj 24.00: BBjWebManager::toggleClass added.

See Also

BBjAPI

BBjSysGui

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.