BBjColorChooser::approveSelection

Description

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

Syntax

Return Value

Method

void

approveSelection()

Parameters

None.

Return Value

None.

Remarks

Although this is a programmatic action, invoking this method causes the BBjColorChooser to dispatch an ON_COLORCHOOSER_APPROVE event, including sending the current color. Use this to synthesize depressing the [OK] button.

Example

rem 'This sample displays a BBjColorChooser in a window, then times out

rem 'after 5 seconds and prints the currently selected color. The default
rem 'color is red (255,0,0)
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 = 500
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,500,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 approve selection dialog
myAPI!.createTimer("timeout", 5, "ACCEPT_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
ACCEPT_COLOR:
    myAPI!.removeTimer("timeout",err = SKIP_APPROVE)
    myColorChooser!.approveSelection()

SKIP_APPROVE:
return

See Also

BBjAPI

BBjSysGui

BBjWindow

BBjColorChooser

BBjColorChooser::cancelSelection

BBjColorChooserApproveEvent

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