BBjPopupMenu::getMenuAt

Description

In BBj 3.0 and higher, this method returns a submenu from a BBjPopupMenu.

Syntax

Return Value

Method

BBjMenu

getMenuAt(int index)

Parameters

Variable

Description

index

Specifies the 0-based index of the menu to be retrieved.

Return Value

Returns the specified BBjMenu object.

Remarks

None.

Example

REM Get a menu from a popup menu

REM Obtain the instance of the BBjAPI object
LET myAPI!=BBjAPI()

REM Open the SysGui device
SYSGUI=UNT
OPEN (SYSGUI)"X0"

REM Obtain the instance of the BBjSysGui object
LET mySysGui!=myAPI!.getSysGui()

REM Set addWindow param values
X=100
Y=100
WIDTH=200
HEIGHT=200
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 a button
myButton! = myWindow!.addButton(1,50,50,90,30,"OK")

REM Add a popup menu to the button
myPopupMenu!=myButton!.addPopupMenu()

REM Add a sub menu to the popup menu
mySubMenu!=myPopupMenu!.addMenu(-200,"Su&b Menu 1")

REM Add menu items to the sub menu
myItem1! = mySubMenu!.addMenuItem(-201,"Sub Menu Item 1")
myItem2! = mySubMenu!.addMenuItem(-202,"Sub Menu Item 2")

REM Retrieve a menu from the popup menu
myNewMenu! = myPopupMenu!.getMenuAt(0)

REM Register the CALLBACK routines
CALLBACK(ON_BUTTON_PUSH,OK,mySysGui!.getContext(),myButton!.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 selects the first item
Item1:
i = msgbox("Item 1 was selected")
return

REM Callback routine invoked when the user selects the second item
Item2:
i = msgbox("Item 2 was selected")
return

REM Callback routine called when the user closes the application window
APP_CLOSE:
RELEASE

See Also

BBjAPI

BBjSysGui Methods

BBjControl Methods

BBjPopupMenu

BBjMenu

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