BBjPopupMenu::insertMenu

Description

In BBj 3.0 and higher, this method inserts a submenu into a BBjMenu.

Syntax

Return Value

Method

BBjMenu

insertMenu(int index, int ID, string title)

Parameters

Variable

Description

index

Specifies the 0-based index at which to insert the menu.

ID

Specifies the ID of the menu that will be added.

title

Specifies the title of the menu.

Return Value

Returns the created BBjMenu object.

Remarks

Each sub menu in the popup menu with an index greater or equal to the specified index is shifted upward to have an index one greater than the value it had previously.

Example

rem 'Insert a sub-menu to 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 some items to the popup menu
myItemA! = myPopupMenu!.addMenuItem(-101,"Menu Item A")
myItemB! = myPopupMenu!.addMenuItem(-102,"Menu Item B")

rem 'Add a sub menu to the popup menu
mySubMenu! = myPopupMenu!.insertMenu(1,-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 'Register the CALLBACK routines
CALLBACK(ON_BUTTON_PUSH,OK,mySysGui!.getContext(),myButton!.getID())
CALLBACK(ON_POPUP_ITEM_SELECT,ItemA,myPopupMenu!.getID(),myItemA!.getID())
CALLBACK(ON_POPUP_ITEM_SELECT,ItemB,myPopupMenu!.getID(),myItemB!.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
ItemA:
    i = msgbox("Item A was selected")
return

rem 'Callback routine invoked when the user selects the second item
ItemB:
    i = msgbox("Item B was selected")
return

rem 'Callback routine invoked when the user selects the first sub-item
Item1:
    i = msgbox("Item 1 was selected")
return

rem 'Callback routine invoked when the user selects the second sub-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

BBjControl

BBjPopupMenu

BBjMenu

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