BBjColorChooser::cancelSelection

Description

In BBj 7.00 and higher, this method programmatically depresses the BBjColorChooser's [Cancel] button.

Syntax

Return Value

Method

void

cancelSelection()

Parameters

None.

Return Value

None.

Remarks

Although this is a programmatic action, invoking this method causes the BBjColorChooser to dispatch an ON_COLORCHOOSER_CANCEL event. Use this to synthesize depressing the [Cancel] button.

Example

rem 'Add a color chooser to a window

rem 'Obtain the instance of the BBjAPI object
let myAPI! = BBjAPI()

rem 'Open the SysGui device
SYSGUI = UNT
OPEN (SYSGUI) "X0"

rem 'Obtain the instance of the BBjSysGui object
let mySysGui! = myAPI!.getSysGui()

rem 'Set addWindow param values
X = 10
Y = 10
WIDTH = 350
HEIGHT = 250
TITLE$ = "Unattended Color Selection"

rem 'Set the current context
mySysGui!.setContext(0)

rem 'Create a window
myWindow! = mySysGui!.addWindow(X,Y,WIDTH,HEIGHT,TITLE$,$00090000$)

rem 'Add a color chooser on the window
red! = mySysGui!.makeColor(255, 0, 0)
myColorChooser! = myWindow!.addColorChooser(101,0,0,350,250,red!)

rem 'Register the CALLBACK routines
CALLBACK(ON_COLORCHOOSER_APPROVE,APPROVED,mySysGui!.getContext(),myColorChooser!.getID())
CALLBACK(ON_COLORCHOOSER_CANCEL,CANCELLED,mySysGui!.getContext(),myColorChooser!.getID())
CALLBACK(ON_CLOSE,CANCELLED,mySysGui!.getContext())

rem 'Set timer for cancel selection dialog
myAPI!.createTimer("timeout", 5, "CANCEL_COLOR")

rem 'Process Events
process_events

rem 'Callback routine called when the colorchooser's OK button is pressed
APPROVED:
    MESSAGE$ = "The color chosen was: " + STR(myColorChooser!.getColor())
    GOSUB FINISH

    rem 'Callback routine called when the colorchooser's Cancel button is
    rem 'pressed or the window is closed without selecting a color

CANCELLED:
    MESSAGE$ = "No color was chosen!"
    GOSUB FINISH

FINISH:
    myAPI!.removeTimer("timeout",err=*proceed)
    myWindow!.destroy()

    rem 'Display a message with the approprate color
    PRINT MESSAGE$
    WAIT 5
release

rem 'If the timer trips before the
CANCEL_COLOR:
    myAPI!.removeTimer("timeout",err = SKIP_CANCEL)
    myColorChooser!.cancelSelection()

SKIP_CANCEL:
return

See Also

BBjAPI

BBjSysGui

BBjWindow

BBjColorChooser

BBjColorChooser::approveSelection

BBjColorChooserCancelEvent

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