Extended Event

Description

In BBj 7.0 and higher, this event allows GUI programs using a READ RECORD event loop to identify and use the extended BBj events

Mandatory/Optional

Mandatory.

Event Mask Bit

None. Event is always visible.

Event Template

context:u(2),code:c(1),id:u(2),flags:u(1),x:u(2),y:u(2)

Field

Description

context

Context of the window on which the BBjColorChooser resides.

code

x

id

Control ID of the BBjColorChooser.

flags

0

x

Callback Constant.

The x value in the templated string will refer to the constant used by BBjControl::setCallback or the CALLBACK Verb. Rather than having a different notify template for each event type, the method BBjAPI::getLastEvent() provides a BBj Event Object with all the necessary information. See the example for intended usage.

y

0

Example

rem 'Listen for extended events

rem 'open sysgui channel
SYSGUI = unt
OPEN(SYSGUI)"X0"
myAPI! = BBjAPI()
mySysGui! = myAPI!.getSysGui()

rem 'Create window with button
myWindow! = mySysGui!.addWindow(100,100,300,300, "READING RECORDS",$00010083$,$10800100$)
myButton! = myWindow!.addButton(101,50,50,100,30,"Show Chooser",$$)
DIM event$:TMPL(SYSGUI)
let eventlen=LEN(EVENT$)
DONE = 0

rem 'Event loop
REPEAT
    READRECORD(SYSGUI,SIZ=eventlen)event$
    SWITCH ASC(event.code$)

        rem 'Button push event
        CASE ASC("B")
            mySysGui!.setContext(1)
            myDialog! = mySysGui!.addWindow(110, 110, 500, 250, "Color Chooser", $00010002$, $$)
            myColorChooser! = myDialog!.addColorChooser(101, 0, 0, 500, 250)
            break

        rem 'Extended events use an external subroutine
        CASE ASC("x")
            GOSUB EXTENDED_HANDLER
            break

        rem 'Window close event handler
        CASE ASC("X")
            rem 'Close program if main window, cancel dialog if dialog window.
            if event.context = myWindow!.getContextID() then DONE = 1 else myColorChooser!.cancelSelection() FI
            break

        rem 'Ignore other events
        CASE DEFAULT
            break
    SWEND
UNTIL DONE
release

EXTENDED_HANDLER:
    rem 'event.x contains the constant to switch on
    SWITCH event.x

        rem 'The BBjColorChooserApproveEvent handler.
        CASE myAPI!.ON_COLORCHOOSER_APPROVE
            ev! = myAPI!.getLastEvent()
            color! = ev!.getColor()
            myDialog!.destroy()
            let MESSAGE$ = "Color chosen was " + STR(color!)
            let DUMMY = MSGBOX(MESSAGE$)
            break

        rem 'The BBjColorChooserCancelEvent handler
        CASE myAPI!.ON_COLORCHOOSER_CANCEL
            myDialog!.destroy()
            let MESSAGE$ = "Cancelled!"
            let DUMMY = MSGBOX(MESSAGE$)
            break

        rem ' Ignore other extended events
        CASE DEFAULT
            break
    SWEND
return

 

See Also

BBjSysGui

CALLBACK Verb

BBjControl::setCallback

BBjSysGuiEvent

BBjAPI::getLastEvent