BBjPopupMenu::addMenuItem

Description

In BBj 3.0 and higher, this method adds a menu item to a BBjPopupMenu.

Syntax

Return Value

Method

BBjMenuItem

addMenuItem(int ID, string title)

BBjMenuItem

addMenuItem(int ID, string title, int action)

BBjMenuItem

addMenuItem(int ID, string title, boolean checkable, boolean checked)

BBjMenuItem

addMenuItem(int ID, string title, boolean checkable, boolean checked, int action)

Parameters

Variable

Description

ID

Specifies the ID of the menu to be added.

title

Specifies the title of the menu item.

action

Specifies one of the following special menu actions:

32027   CUT

32028   COPY

32029   PASTE

checkable

Specifies whether the menu item is checkable.

checked

Specifies whether the menu item is checked if it is checkable.

Return Value

Returns the created BBjMenuItem object.

Remarks

None.

Example

REM Add menu items 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=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 an edit box
oneEditBox! = myWindow!.addEditBox(101,10,10,180,30,"first text control")

REM Add a popup menu to the control
myPopupMenu!=oneEditBox!.addPopupMenu()

REM Add menu items to the popup menu
myItem1! = myPopupMenu!.addMenuItem(-201,"Item 1")
myItem2! = myPopupMenu!.addMenuItem(-202,"Item 2")
myItem3! = myPopupMenu!.addMenuItem(-203,"Item 3",1,0)
myItem4! = myPopupMenu!.addMenuItem(-204,"Item 4",1,1)
myPopupMenu!.addMenuItem(-mySysGui!.CUT,"Cu&t")
myPopupMenu!.addMenuItem(-mySysGui!.COPY,"&Copy")
myPopupMenu!.addMenuItem(-mySysGui!.PASTE,"&Paste")

REM Create another edit box
twoEditBox! = myWindow!.addEditBox(102,10,50,180,30,"second text control")

REM Add a popup menu to the control
myPopupMenu2!=twoEditBox!.addPopupMenu()

REM Add menu items to the popup menu
myPopupMenu2!.addMenuItem(-mySysGui!.CUT,"Cu&t")
myPopupMenu2!.addMenuItem(-mySysGui!.COPY,"&Copy")
myPopupMenu2!.addMenuItem(-mySysGui!.PASTE,"&Paste")

REM Register the CALLBACK routines
CALLBACK(ON_POPUP_ITEM_SELECT,Item1,myPopupMenu!.getID(),myItem1!.getID())
CALLBACK(ON_POPUP_ITEM_SELECT,Item2,myPopupMenu!.getID(),myItem2!.getID())
CALLBACK(ON_POPUP_ITEM_SELECT,Item3,myPopupMenu!.getID(),myItem3!.getID())
CALLBACK(ON_POPUP_ITEM_SELECT,Item4,myPopupMenu!.getID(),myItem4!.getID())
CALLBACK(ON_CLOSE,APP_CLOSE,mySysGui!.getContext())

REM Process Events
PROCESS_EVENTS

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 invoked when the user selects the third item
Item3:
if myItem3!.isSelected() then state$="ON" else state$="OFF"
i = msgbox("Item 3 was selected and is now checked "+state$)
return

REM Callback routine invoked when the user selects the fourth item
Item4:
if myItem4!.isSelected() then state$="ON" else state$="OFF"
i = msgbox("Item 4 was selected and is now checked "+state$)
return

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

See Also

BBjAPI

BBjSysGui Methods

BBjControl Methods

BBjPopupMenu

Keyboard Focus, Keyboard Navigation, and the Default Button

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