
CALLBACK Verb - Register BBj Subroutine
Syntax
CALLBACK (eventType,subroutineName,contextID,{controlID})
or
CALLBACK (eventType,publicProgramEntryPoint,contextID,{controlID})
Description
A CALLBACK is used to execute a block of code at a given location when a specific event occurs. In some cases, this is tied to a specific control via the controlID.
The CALLBACK verb will implicitly GOSUB to the subroutine specified in subroutineName. Since the block of code executed at subroutineName is arrived at via an implicit GOSUB, a RETURN is required at the end of the subroutine.
The CALLBACK implicitly CALLs the publicProgram at the given EntryPoint when the CALLBACK VERB uses the publicProgramEntryPoint syntax (ie: "publicProgram::EntryPoint"). Since a CALL has been made to a public program, an ENTER may optionally be used at the beginning, and a EXIT is required at the end.
CALLBACKS must be registered before the PROCESS_EVENTS verb or within
a SUBROUTINE that is called in response to an event.
The REMOVE_CALLBACK
verb removes event handling for the eventType
(specified event for a control).
For more information, see PROCESS_EVENTS.
Parameter |
Description |
---|---|
eventType |
An event type as seen in the table below. |
subroutineName |
A name of a subroutine that starts with and Alpha character and contains any number of alpha, numeric, and underscore characters. |
contextID |
An integer value between 0 and 32767. |
controlID |
Control ID number, which must be an integer between 1 and 32767 and unique within a given top-level window. Optional for window events. |
publicProgramEntryPoint |
A string of the form "publicProgramName::entryPoint". This parameter must be a BBj string expression:
CALLBACK(ON_BUTTON_PUSH,"foo::bar",0,101)
And so is this: SUB$="foo::bar" CALLBACK(ON_BUTTON_PUSH,SUB$,0,101)
But this is a syntax error: CALLBACK(ON_BUTTON_PUSH,foo::bar,0,101) |
Window Events
Callback Syntax |
Event |
Code |
---|---|---|
ON_ACTIVATE |
A |
|
ON_CLOSE |
X |
|
ON_COLOR_CHANGE |
s |
|
ON_DEACTIVATE |
A |
|
ON_DOUBLE_CLICK |
2 |
|
ON_KEYPRESS |
t |
|
ON_MDI_CLOSING |
M |
|
ON_MINIMIZE |
A |
|
d |
||
ON_MOUSE_ENTER |
E |
|
ON_MOUSE_EXIT |
E |
|
ON_MOUSE_MOVE |
m |
|
ON_MOUSE_SCROLL |
w |
|
ON_MOUSE_UP |
u |
|
ON_RESIZE |
S |
|
ON_RESTORE |
A |
|
ON_SCREEN_RESIZE |
s |
|
ON_WINDOW_GAINED_FOCUS |
F |
|
ON_WINDOW_LOST_FOCUS |
F |
|
ON_WINDOW_MOVE |
L |
|
ON_WINDOW_SCROLL |
p |
Menu Events
Callback Syntax |
Event |
Code |
---|---|---|
ON_MENU_ITEM_SELECT |
C |
Popup Menu Events
Callback Syntax |
Event |
Code |
---|---|---|
ON_POPUP_ITEM_SELECT |
r |
Control Events
Callback Syntax |
Event |
Code |
---|---|---|
ON_BUTTON_PUSH |
B |
|
ON_CHECK_OFF |
c |
|
ON_CHECK_ON |
c |
|
ON_COLORCHOOSER_APPROVE |
|
|
ON_COLORCHOOSER_CANCEL |
|
|
ON_COLORCHOOSER_CHANGE |
|
|
ON_CONTROL_SCROLL |
p |
|
ON_CONTROL_VALIDATION |
v |
|
ON_DB_GRID_ROW_CHANGE_REQUEST (BBj 7.0 and higher) |
N/A |
|
ON_DRAG_SOURCE_DROP |
O |
|
ON_DROP_TARGET_DROP |
D |
|
ON_EDIT_KEYPRESS |
N (Notify code 1) |
|
ON_EDIT_MODIFY |
e |
|
ON_FILECHOOSER_APPROVE |
x |
|
ON_FILECHOOSER_CANCEL |
x |
|
ON_FILECHOOSER_CHANGE |
x |
|
ON_FILECHOOSER_FILTER |
x |
|
ON_FONTCHOOSER_APPROVE |
x |
|
ON_FONTCHOOSER_CANCEL |
x |
|
ON_FONTCHOOSER_CHANGE |
x |
|
ON_FORM_VALIDATION |
V |
|
ON_GAINED_FOCUS |
f |
|
ON_GRID_CELL_MODIFY |
N (Notify code 5) |
|
ON_GRID_CELL_QUERY |
N (Notify code 33) |
|
ON_GRID_CELL_VALIDATION |
N (Notify code 32) |
|
ON_GRID_CHECK_OFF |
N (Notify code 30) |
|
ON_GRID_CHECK_ON |
N (Notify code 30) |
|
ON_GRID_COLUMN_SIZE |
N (Notify code 1) |
|
ON_GRID_DOUBLE_CLICK |
N (Notify code 3) |
|
ON_GRID_DRAG_DROP |
N (Notify code 4) |
|
ON_GRID_EDIT_START |
N (Notify code 8) |
|
ON_GRID_EDIT_STOP |
N (Notify code 7) |
|
ON_GRID_ENTER_KEY |
N (Notify code 9) |
|
ON_GRID_ERROR |
N (Notify code 29) |
|
ON_GRID_GAINED_FOCUS |
N (Notify code 20) |
|
ON_GRID_HIT_BOTTOM |
N (Notify code 10) |
|
ON_GRID_HIT_TOP |
N (Notify code 11) |
|
ON_GRID_KEYPRESS |
N (Notify code 12) |
|
ON_GRID_LEFT_COLUMN_CHANGE |
N (Notify code 16) |
|
ON_GRID_LIST_CANCEL |
N (Notify code 34) |
|
ON_GRID_LIST_CHANGE |
N (Notify code 35) |
|
ON_GRID_LIST_CLICK |
N (Notify code 36) |
|
ON_GRID_LIST_CLOSE |
N (Notify code 37) |
|
ON_GRID_LIST_OPEN |
N (Notify code 38) |
|
ON_GRID_LIST_SELECT |
N (Notify code 39) |
|
ON_GRID_LOST_FOCUS |
N (Notify code 13) |
|
ON_GRID_MOUSE_DOWN |
N (Notify code 14) N (Notify code 15) |
|
ON_GRID_MOUSE_DRAG |
N (Notify code 17) |
|
ON_GRID_MOUSE_MOVE |
N (Notify code 17) |
|
ON_GRID_MOUSE_UP |
N (Notify code 14) |
|
ON_GRID_RIGHT_MOUSE_DOWN |
N (Notify code 18) |
|
ON_GRID_RIGHT_MOUSE_UP |
N (Notify code 18) |
|
ON_GRID_ROW_DELETE |
N (Notify code 25) |
|
ON_GRID_ROW_INSERT |
N (Notify code 24) |
|
ON_GRID_ROW_INSERT_CANCEL |
N (Notify code 26) |
|
ON_GRID_ROW_UPDATE |
N (Notify code 27) |
|
ON_GRID_ROW_VALIDATION |
N (Notify code 31) |
|
ON_GRID_SELECT_COLUMN |
N (Notify code 2) |
|
ON_GRID_SELECT_ROW |
N (Notify code 19) |
|
ON_GRID_SPECIAL_KEY |
N (Notify code 6) |
|
ON_GRID_TOP_ROW_CHANGE |
N (Notify code 21) |
|
ON_GRID_UPDATE |
N (Notify code 22) |
|
ON_HYPERLINK_ACTIVATE |
x |
|
ON_HYPERLINK_ENTER |
x |
|
ON_HYPERLINK_EXIT |
x |
|
ON_INPUT_KEYPRESS |
N (Notify Code 1) |
|
ON_LIST_CANCEL |
N (Notify code 4) |
|
ON_LIST_CHANGE |
N (Notify code 5) |
|
ON_LIST_CLICK |
l (lower case L) |
|
ON_LIST_CLOSE |
N (Notify code 3) |
|
ON_LIST_DOUBLE_CLICK |
l (lower case L) |
|
ON_LIST_OPEN |
N (Notify code 1) |
|
ON_LIST_SELECT |
N (Notify code 2) |
|
ON_LOST_FOCUS |
f |
|
ON_MOUSE_ENTER |
E |
|
ON_MOUSE_EXIT |
E |
|
ON_NAV_FIRST |
N (Notify code 1) |
|
ON_NAV_LAST |
N (Notify code 1) |
|
ON_NAV_NEXT |
N (Notify code 1) |
|
ON_NAV_PREVIOUS |
N (Notify code 1) |
|
ON_PAGE_LOADED |
|
|
ON_POPUP_REQUEST |
p |
|
ON_RIGHT_MOUSE_DOWN |
R |
|
ON_SPIN |
N/A |
|
ON_TAB_DESELECT |
N (Notify code 3) |
|
ON_TAB_KEYPRESS |
N (Notify code 1) |
|
ON_TAB_SELECT |
N (Notify code 2) |
|
ON_TOOL_BUTTON_PUSH |
b |
|
ON_TREE_COLLAPSE |
N (Notify Code 4) |
|
ON_TREE_DESELECT |
N (Notify Code 2) |
|
ON_TREE_DOUBLE_CLICK |
N (Notify Code 7) |
|
ON_TREE_EDIT_STOP |
N (Notify Code 5) |
|
ON_TREE_EXPAND |
N (Notify Code 3) |
|
ON_TREE_MOUSE_DOWN |
N (Notify Code 6) |
|
ON_TREE_MOUSE_UP |
N (Notify Code 6) |
|
ON_TREE_RIGHT_MOUSE_DOWN |
N (Notify Code 8) |
|
ON_TREE_RIGHT_MOUSE_UP |
N (Notify Code 8) |
|
ON_TREE_SELECT |
N (Notify Code 1) |
Other Events
Callback Syntax |
Event |
Code |
---|---|---|
ON_GEOLOCATION_POSITION |
N/A |
G |
ON_GEOLOCATION_WATCH |
N/A |
G |
ON_NAMESPACE_SET |
N (Notify Code 1) |
|
ON_NAMESPACE_CHANGE |
N (Notify Code 2) |
|
ON_TIMER |
T |
|
ON_WEB_CONNECTION |
N/A |
|
Example
REM CallBack Example SYSGUI=UNT OPEN (SYSGUI)"X0" SysGui! = BBjAPI().getSysGui()
REM Create Controls PRINT (SYSGUI)'WINDOW'(50,50,400,200,"Example",$00090003$) PRINT (SYSGUI)'EDIT'(100,50,50,125,25,"",$$) PRINT (SYSGUI)'EDIT'(103,200,50,125,25,"",$$) PRINT (SYSGUI)'BUTTON'(110,62,125,75,25,"Button 1",$$) PRINT (SYSGUI)'BUTTON'(111,212,125,75,25,"Button 2",$$)
REM Build the event base info templates DIM GENERIC$:NOTICETPL(0,0) DIM EVENT$:TMPL(SYSGUI)
CONTEXT = 0 VAR = 2
REM PublicProgramEntryPoint CALLBACK(ON_BUTTON_PUSH,pgm(-2)+"::BUTTON1_PUSH",CONTEXT,110) REM Subroutine Name CALLBACK(ON_BUTTON_PUSH,BUTTON2_PUSH,CONTEXT,111) CALLBACK(ON_EDIT_MODIFY,EDIT_MODIFY,CONTEXT,100) CALLBACK(ON_EDIT_MODIFY,EDIT_MODIFY,CONTEXT,103) CALLBACK(ON_CLOSE,EXIT_PROGRAM,CONTEXT,0)
REM Process Events PROCESS_EVENTS
REM This Callback is registered using PublicProgramEntryPoint REM and therefore can Optionally do an ENTER REM and always uses an EXIT. BUTTON1_PUSH: ENTER PRINT (SYSGUI)'TITLE'(100,"Button 1: VAR = "+str(VAR)) PRINT (SYSGUI)'TITLE'(103,"") EXIT
REM This Callback is registered using SubroutineName REM and therfore does a RETURN BUTTON2_PUSH: PRINT (SYSGUI)'TITLE'(100,"") PRINT (SYSGUI)'TITLE'(103,"You Pressed Button 2!") RETURN
REM This Callback is registered using SubroutineName REM and therfore does a RETURN EDIT_MODIFY: event! = sysgui!.getLastEvent() print "Edit control contains: ",event!.getText() RETURN
EXIT_PROGRAM: RELEASE |