REM Remove the dropdown menu from a menu button control
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 BBjMenuButtons menuButton1! = myWindow!.addMenuButton(101,0,0,100,22,"MenuButton1") menuButton2! = myWindow!.addMenuButton(102,100,0,100,22,"MenuButton2")
REM Create a dropdown menu myDropdownMenu!=mySysGui!.addPopupMenu() myDropdownItem1! = myDropdownMenu!.addMenuItem(-201,"Dropdown Item 1") myDropdownItem2! = myDropdownMenu!.addMenuItem(-202,"Dropdown Item 2")
REM Associate dropdown menu with the buttons menuButton1!.setDropdownMenu(myDropdownMenu!) menuButton2!.setDropdownMenu(myDropdownMenu!)
REM Create a popup menu myPopupMenu!=mySysGui!.addPopupMenu() myPopupItem1! = myPopupMenu!.addMenuItem(-301,"Popup Item 1") myPopupItem2! = myPopupMenu!.addMenuItem(-302,"Popup Item 2")
REM Associate popup menu with the buttons menuButton1!.setPopupMenu(myPopupMenu!) menuButton2!.setPopupMenu(myPopupMenu!)
REM Register the CALLBACK routines CALLBACK(ON_BUTTON_PUSH,MenuButton1,mySysGui!.getContext(),MenuButton1!.getID()) CALLBACK(ON_BUTTON_PUSH,MenuButton2,mySysGui!.getContext(),MenuButton2!.getID()) CALLBACK(ON_POPUP_ITEM_SELECT,DropdownItem1,myDropdownMenu!.getID(),myDropdownItem1!.getID()) CALLBACK(ON_POPUP_ITEM_SELECT,DropdownItem2,myDropdownMenu!.getID(),myDropdownItem2!.getID()) CALLBACK(ON_POPUP_ITEM_SELECT,PopupItem1,myPopupMenu!.getID(),myPopupItem1!.getID()) CALLBACK(ON_POPUP_ITEM_SELECT,PopupItem2,myPopupMenu!.getID(),myPopupItem2!.getID()) CALLBACK(ON_CLOSE,APP_CLOSE,mySysGui!.getContext())
REM Process Events PROCESS_EVENTS
REM Callback routine invoked when the user clicks the button MenuButton1: event! = mySysGui!.getLastEvent() event$ = mySysGui!.getLastEventString() i = msgbox("MenuButton1 was clicked") return
REM Callback routine invoked when the user clicks the button MenuButton2: event! = mySysGui!.getLastEvent() event$ = mySysGui!.getLastEventString() if menuButton2!.getDropdownMenu() = null() i = msgbox("MenuButton2 was clicked.") else menuButton2!.removeDropdownMenu() i = msgbox("MenuButton2 was clicked; dropdown menu was removed.") endif return
REM Callback routine invoked when the user selects the first dropdown item DropdownItem1: event! = mySysGui!.getLastEvent() event$ = mySysGui!.getLastEventString() i = msgbox("Dropdown Item 1 was selected on "+event!.getControl().getText()) return
REM Callback routine invoked when the user selects the second dropdown item DropdownItem2: event! = mySysGui!.getLastEvent() event$ = mySysGui!.getLastEventString() i = msgbox("Dropdown Item 2 was selected on "+event!.getControl().getText()) return
REM Callback routine invoked when the user selects the first popup item PopupItem1: event! = mySysGui!.getLastEvent() event$ = mySysGui!.getLastEventString() i = msgbox("Popup Item 1 was selected on "+event!.getControl().getText()) return
REM Callback routine invoked when the user selects the second popup item PopupItem2: event! = mySysGui!.getLastEvent() event$ = mySysGui!.getLastEventString() i = msgbox("Popup Item 2 was selected on "+event!.getControl().getText()) return
REM Callback routine called when the user closes the application window APP_CLOSE: RELEASE
|