rem ' BBjWebComponent Debounce & Throttle
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
window! = sysgui!.addWindow(25,25,300,300,"Debounce & Throttle",$00090083$)
window!.setCallback(window!.ON_CLOSE,"eoj")
button! = window!.addWebComponent(101,25,25,250,25,"button")
button!.setText("Click Immediate")
button!.setAttribute("title","Click events are reported immediately")
button!.setCallback("click","event")
options! = button!.newEventOptions()
options!.setImmediate(); rem ' this is the default
System.out.println("getImmediate = " + Boolean.toString(options!.getImmediate()))
throttle! = window!.addWebComponent(102,25,75,250,25,"button")
throttle!.setText("Click Throttle")
options! = throttle!.newEventOptions()
options!.setThrottle(1000)
throttle!.setAttribute("title","Click events are throttled to once per second.")
throttle!.setCallback("click","event",options!)
System.out.println("getThrottle = " + Boolean.toString(options!.getThrottle()))
System.out.println("getDelay = " + str(options!.getDelay()))
debounce! = window!.addWebComponent(103,25,125,250,25,"button")
debounce!.setText("Click Debounce")
options! = debounce!.newEventOptions()
options!.setDebounce(1000,Boolean.TRUE,Boolean.FALSE)
debounce!.setAttribute("title","Click events are debounced to once per second.")
debounce!.setCallback("click","event",options!)
System.out.println("getDebounce = " + Boolean.toString(options!.getDebounce()))
System.out.println("getDelay = " + str(options!.getDelay()))
System.out.println("getLeading = " + Boolean.toString(options!.getLeading()))
System.out.println("getTrailing = " + Boolean.toString(options!.getTrailing()))
status! = window!.addStatusBar(99)
process_events
eoj:
release
event:
event! = sysgui!.getLastEvent()
msg$ = date(0:"%Hz:%mz:%sz.%tz")
msg$ = msg$ + " " + event!.getEventType()
msg$ = msg$ + " " + event!.getControl().getText()
status!.setText(msg$)
System.out.println(msg$)
return
|