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.