BBjButton::setDisableOnClick

Description

In BBj 16.00 and higher, this method sets a boolean value indicating whether this BBjButton should be immediately disabled when the user clicks it.

Syntax

Return Value

Method

void

setDisableOnClick(boolean disable)

Parameters

Variable

Description

disable

Specifies whether this button should be immediately disabled when the user clicks it.

0 = Don't disable on click (default).

1 = Disable this button when the user clicks it.

Return Value

None.

Remarks

When clicking a button triggers a long-running action, the application might want to ensure that only a single click is processed.  This can be an issue in high-latency environments when the user clicks the button multiple times before the application has had a chance to start processing the resulting action.

Example

rem ' BBjButton::setDisableOnClick

begin
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
title$ = "setDisableOnClick"
window! = sysgui!.addWindow(100,100,415,300,title$,$00090003$,$$)
window!.setCallback(window!.ON_CLOSE,"eoj")

rem ' BBjButton
dboc! = window!.addCheckBox(100,10,10,125,25,"Disable on click",$$)
dboc!.setCallback(dboc!.ON_CHECK_ON,"dboc_on")
dboc!.setCallback(dboc!.ON_CHECK_OFF,"dboc_off")
button! = window!.addButton(101,145,10,100,25,"Button",$$)
button!.setCallback(button!.ON_BUTTON_PUSH,"button")
eb! = window!.addCheckBox(102,280,10,100,25,"Enabled",$0004$)
eb!.setCallback(eb!.ON_CHECK_ON,"eb_on")
eb!.setCallback(eb!.ON_CHECK_OFF,"eb_off")

rem ' BBjMenuButton
dmoc! = window!.addCheckBox(200,10,50,125,25,"Disable on click",$$)
dmoc!.setCallback(dmoc!.ON_CHECK_ON,"dmoc_on")
dmoc!.setCallback(dmoc!.ON_CHECK_OFF,"dmoc_off")
menubutton! = window!.addMenuButton(201,145,50,100,25,"MenuButton",$4000$)
menubutton!.setCallback(menubutton!.ON_BUTTON_PUSH,"menubutton")
em! = window!.addCheckBox(202,280,50,100,25,"Enabled",$0004$)
em!.setCallback(em!.ON_CHECK_ON,"em_on")
em!.setCallback(em!.ON_CHECK_OFF,"em_off")

rem ' BBjToolButton
dtoc! = window!.addCheckBox(300,10,90,125,25,"Disable on click",$$)
dtoc!.setCallback(dmoc!.ON_CHECK_ON,"dtoc_on")
dtoc!.setCallback(dmoc!.ON_CHECK_OFF,"dtoc_off")
toolbutton! = window!.addToolButton(301,145,90,100,25,"ToolButton",$$)
toolbutton!.setCallback(toolbutton!.ON_TOOL_BUTTON_PUSH,"toolbutton")
et! = window!.addCheckBox(302,280,90,100,25,"Enabled",$0004$)
et!.setCallback(et!.ON_CHECK_ON,"et_on")
et!.setCallback(et!.ON_CHECK_OFF,"et_off")

rem ' Events
events! = window!.addCEdit(999,10,130,395,160,$$,$8184$)
events = 0, x$ = ""
window!.focus()
process_events

eoj:
release

event:
    e! = sysgui!.getLastEvent()
    e$ = str(e!), p = pos("@" = e$); if p then e$ = e$(1,p-1)
    c! = e!.getControl()
    c$ = str(c!), p = pos("@" = c$); if p then c$ = c$(1,p-1)
    events = events + 1
    x$ = str(System.currentTimeMillis())
    event$ = str(events)+" "+x$+" "+c$+" "+str(c!.getID())+" "+e$
    print event$
    events!.addParagraph(-1,event$)
    events!.highlight(-1,0,-1,0)
    x$ = ""
return

button:
    gosub event
    eb!.setSelected(button!.isEnabled())
return

dboc_on:
    button!.setDisableOnClick(1)
    print button!," getDisableOnClick ",button!.getDisableOnClick()
return

dboc_off:
    button!.setDisableOnClick(0)
    print button!," getDisableOnClick ",button!.getDisableOnClick()
return

eb_on:
    button!.setEnabled(1)
return

eb_off:
    button!.setEnabled(0)
return

menubutton:
    gosub event
    em!.setSelected(menubutton!.isEnabled())
return

dmoc_on:
    menubutton!.setDisableOnClick(1)
    print menubutton!," getDisableOnClick ",menubutton!.getDisableOnClick()
return

dmoc_off:
    menubutton!.setDisableOnClick(0)
    print menubutton!," getDisableOnClick ",menubutton!.getDisableOnClick()
return

em_on:
    menubutton!.setEnabled(1)
return

em_off:
    menubutton!.setEnabled(0)
return

toolbutton:
    gosub event
    et!.setSelected(toolbutton!.isEnabled())
return

dtoc_on:
    toolbutton!.setDisableOnClick(1)
    print toolbutton!," getDisableOnClick ",toolbutton!.getDisableOnClick()
return

dtoc_off:
    toolbutton!.setDisableOnClick(0)
    print toolbutton!," getDisableOnClick ",toolbutton!.getDisableOnClick()
return

et_on:
    toolbutton!.setEnabled(1)
return

et_off:
    toolbutton!.setEnabled(0)
return

See Also

BBjAPI

BBjSysGui

BBjControl

BBjWindow

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