REM Create a popup menu and assign it to multiple
controls
REM Obtain the instance of the BBjAPI object LET myAPI!=BBjAPI()
REM Open the SysGui device SYSGUI=UNT OPEN (SYSGUI)"X0" DIM EVENT$:TMPL(SYSGUI)
REM Obtain the instance of the BBjSysGui object LET mySysGui!=myAPI!.getSysGui()
REM Set addWindow param values X=100 Y=100 WIDTH=200 HEIGHT=100 TITLE$="BBj Window"
REM Set the current context mySysGui!.setContext(0) REM Create a window with a title in the current context myWindow! = mySysGui!.addWindow(X,Y,WIDTH,HEIGHT,TITLE$)
REM Create buttons okButton! = myWindow!.addButton(1,5,50,90,30,"OK") cancelButton! = myWindow!.addButton(2,100,50,90,30,"Cancel")
REM Create a popup menu myPopupMenu!=mySysGui!.addPopupMenu() myItem1! = myPopupMenu!.addMenuItem(-201,"Item 1") myItem2! = myPopupMenu!.addMenuItem(-202,"Item 2")
REM Associate popup menu with the buttons okButton!.setPopupMenu(myPopupMenu!) cancelButton!.setPopupMenu(myPopupMenu!)
REM Register the CALLBACK routines CALLBACK(ON_BUTTON_PUSH,OK,mySysGui!.getContext(),okButton!.getID()) CALLBACK(ON_BUTTON_PUSH,Cancel,mySysGui!.getContext(),cancelButton!.getID()) CALLBACK(ON_POPUP_ITEM_SELECT,Item1,myPopupMenu!.getID(),myItem1!.getID()) CALLBACK(ON_POPUP_ITEM_SELECT,Item2,myPopupMenu!.getID(),myItem2!.getID()) CALLBACK(ON_CLOSE,APP_CLOSE,mySysGui!.getContext())
REM Process Events PROCESS_EVENTS
REM Callback routine invoked when the user clicks the button OK: i = msgbox("OK Button was selected") return
REM Callback routine invoked when the user clicks the button Cancel: i = msgbox("Cancel Button was selected") return
REM Callback routine invoked when the user selects the first item Item1: event$ = mySysGui!.getLastEventString() i = msgbox("Popup Item 1 was selected on control ID "+str(event.id)) return
REM Callback routine invoked when the user selects the second item Item2: event$ = mySysGui!.getLastEventString() i = msgbox("Popup Item 2 was selected on control ID "+str(event.id)) return
REM Callback routine called when the user closes the application
window APP_CLOSE: RELEASE
|