BBjControl::toggleClass

Description

In BBj 24.00 and higher, this method toggles a CSS class name on the BBjControl.

Syntax

Return Value Method
boolean toggleClass(String className)

Parameters

Parameter Description
className Specifies a CSS class name to be toggled on the control.

Return Value

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

BUI logoDWC logoRemarks

In the BUI and DWC browser clients, this corresponds to Element::classList::toggle.

Example

rem ' BBjControl::toggleClass

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

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$)

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:
  text!.addClass(class!.getText(),err=*next); return
  i = msgbox(errmes(-1),0,"addClass")
return

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

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

getClassList:
   classList! = text!.getClassList()
   i = msgbox(str(classList!),0,"getClassList()")
return

ClosedVersion History

  • BBj 24.00: BBjControl::toggleClass added.

See Also

BBjAPI

BBjSysGui

BBjWindow

CSS API

Element.classList

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