BBjWindow::getMenuItem

Description

In BBj 7.0 and higher, this method returns a BBjControl object in the BBjWindow cast to a BBjMenuItem.

In BBj 11.0 and higher, this method supports reference to the BBjMenuItem by name with a (string name) parameter.

Syntax

Return Value

Method

BBjMenuItem

getMenuItem(int controlID)

BBjMenuItem

getMenuItem(string name)

Parameters

Parameter Description
controlID Specifies the ID of the control. A value of 0 may be used to get information about a context's window or dialog rather than an individual control or child window (as defined in the CTRL() function).
name Specifies name given to a BBj control using the setName method.

Return Value

This convenience method calls getControl() and casts the result to a BBjMenuItem.

Remarks

If the control that generated this event is not a BBjMenuItem, this method will generate an !ERROR=26.

Example

rem 'Demostrate use of BBjWindow::getMenuItem()

declare BBjSysGui sysgui!
declare BBjTopLevelWindow win!
declare BBjMenuBar menubar!
declare BBjMenu menu!
declare BBjMenuItem menuItem!
declare BBjMenuItemSelectEvent event!

sysgui! = BBjAPI().openSysGui("X0")

win! = sysgui!.addWindow(100,100,300,200,"Window with menu")
menuBar! = win!.addMenuBar()
menu! = menuBar!.addMenu(-1,"File")
menuItem! = menu!.addMenuItem(-10,"New")
menuItem! = menu!.addMenuItem(-11,"Open")
menuItem! = menu!.addMenuItem(-12,"Save")
menuItem! = menu!.addMenuItem(-13,"Save As")
menuItem! = menu!.addMenuItem(-14,"Close")
menuItem! = menu!.addMenuItem(-15,"Exit")
menuItem!.setCallback(menuItem!.ON_MENU_ITEM_SELECT,"exit_pressed")

rem 'Get the "Save" menu item for the window and print its name.
menuItem! = win!.getMenuItem(-12)
print menuItem!.getText()

process_events

exit_pressed:
release

See Also

String Templates

BBjAPI

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