bbj40.gif BBjPopupMenu


Creation Path


BBjAPI

|

+--BBjSysGui

|

+--BBjPopupMenu

Description

In BBj 4.0 and higher, the BBjPopupMenu object provides methods for manipulating a GUI popup menu associated with a control.

Creation

A BBjPopupMenu object is manipulated through the following BBjSysGui methods:

Return Value

Method

BBjPopupMenu

addPopupMenu()

BBjPopupMenu

createPopupMenu(int resHandle, int popupMenuID)

BBjPopupMenu objects can also be manipulated through the following BBjControl methods, which are inherited by all control types except menus:

Return Value

Method

BBjPopupMenu

addPopupMenu()

BBjPopupMenu

getPopupMenu()

BBjPopupMenu

removePopupMenu()

void

setPopupMenu(BBjPopupMenu popupMenu!)

Methods of BBjPopupMenu

Return Value

Method

BBjMenu

addMenu(int ID, string title)

BBjMenuItem

addMenuItem(int ID, string title)

BBjMenuItem

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

BBjMenuItem

addMenuItem(int ID, string title, int action)

void

addSeparator()

BBjControl

getControl(int ID)

int

getID(int index)

BBjMenu

getMenu(int ID)

BBjMenu

getMenuAt(int index)

BBjMenuItem

getMenuItem(int ID)

BBjMenuItem

getMenuItemAt(int index)

int

getMenuItemIDAt(int index)

BBjMenu

insertMenu(int index, int ID, string title)

BBjMenuItem

insertMenuItem(int index, int ID, string title)

BBjMenuItem

insertMenuItem(int index, int ID, string title, int action)

BBjMenuItem

insertMenuItem(int index, int ID, string title, int checkable, int checked)

void

insertSeparator(int index)

void

removeMenu(BBjMenu menu)

void

removeMenu(int ID)

void

removeMenuAt(int index)

void

removeMenuItem(BBjMenuItem item)

void

removeMenuItem(int ID)

void

removeMenuItemAt(BBjMenuItem index)

void

removeSeparator(int index)

void

show(BBjControl control!, int x, int y)

void

show(int context, int control, int x, int y)

Events

Callback Code

Object-oriented Event

Read Record Event

Code

ON_POPUP_ITEM_SELECT

BBjPopupSelectEvent

Popup Selection Event

P

ON_POPUP_REQUEST

BBjPopupRequestEvent

Popup Request Event

r

Remarks

All ID values should be negative. If they are not specified as negative values, they will be converted to negative values internally.

All index values are zero-based.

BBjPopupMenu: The BBjPopupMenu appears when the user presses the appropriate mouse button (usually right-click) on a control that has an associated BBjPopupMenu. BBjMenus and/or BBjMenuItems are added to the BBjPopupMenu.

BBjMenu: A BBjMenu object is a menu that can have menu items and submenus within the object. BBjMenu objects can be added to the BBjMenuBar and to other BBjMenus. When they are added to other BBjMenus, an arrow will point from the title and when the arrow is rolled-over, the submenu will appear.

BBjMenuItem: A BBjMenuItem object is a menu item that is not a submenu. They can be added to a BBjMenu or directly to the BBjPopupMenu. A BBjMenuItem can be checkable. In this case, a check will appear next to the menu item's title. When the item is selected, the check will toggle.

The image below illustrates the structure of a popup menu with a submenu:

popup.gif

Constants inherited from BBjControl

Example

REM Create 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 a button
myButton! = myWindow!.addButton(1,55,35,90,30,"OK")

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

REM Add menu items to the popup menu
myItem1! = myPopupMenu!.addMenuItem(-201,"Item 1")
myItem2! = myPopupMenu!.addMenuItem(-202,"Item 2")

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

BBjWindow

BBjControl Methods

CALLBACK Verb - Register BBj Subroutine

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