BBjMenuButton::getDropdownMenu

Description

In BBj 7.0 and higher, this BBjMenuButton method retrieves the dropdown menu from a menu button control.

Syntax

Return Value

Method

BBjPopupMenu

getDropdownMenu()

Parameters

None.

Return Value

Returns a BBjPopupMenu object.

Remarks

None.

Example

rem 'Get 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 'Get dropdown menus
dropdownMenu1! = menuButton1!.getDropdownMenu()
dropdownMenu2! = menuButton2!.getDropdownMenu()

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()
    i = msgbox("MenuButton2 was clicked")
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

See Also

BBjAPI

Object Variables

BBjControl::addPopupMenu

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.