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

BBjCheckableMenuItem

addCheckableMenuItem(int ID, string title)

BBjCheckableMenuItem

addCheckableMenuItem(int ID, string title, boolean checked)

BBjMenu

addMenu(int ID, string title)

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)

void

addSeparator()

BBjCheckableMenuItem

getCheckableMenuItem(int ID)

BBjCheckableMenuItem

getCheckableMenuItemAt(int index)

int

getChildCount()

BBjControl

getControl(int ID)

BBjFont

getFont()

int

getID()

int

getMaximumRowCount()

BBjMenu

getMenu(int ID)

BBjMenu

getMenuAt(int index)

BBjMenuItem

getMenuItem(int ID)

BBjMenuItem

getMenuItemAt(int index)

int

getMenuItemIDAt(int index)

Object

getUserData()

void

hide()

BBjCheckableMenuItem

insertCheckableMenuItem(int index, int ID, string title)

BBjCheckableMenuItem

insertCheckableMenuItem(int index, int ID, string title, boolean checked)

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, boolean checkable, boolean checked)

BBjMenuItem

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

void

insertSeparator(int index)

boolean

isVisible()

void

removeMenu(BBjMenu menu!)

void

removeMenu(int ID)

void

removeMenuAt(int index)

void

removeMenuItem(BBjMenuItem item!)

void

removeMenuItem(int ID)

void

removeMenuItemAt(int index)

void

removeSeparator(int index)

void

setFont(BBjFont font!)

void

setMaximumRowCount(int max)

void

setUserData(Object object)

void

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

void

show(int context, int ID, 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

CSS

The visual appearance of BUI controls is defined using CSS (cascading style sheets) rules. Easily change the default colors, border, and other settings by customizing these rules, all without changing any application code. See CSS API for a high level overview of BUI CSS.

The BBjPopupMenu defines the following style names:

.BBjPopupMenu (the top level control)

.BBjPopupMenu-menu (the vertical menu contained within the popup menu)

The BBjPopupMenu contains BBjMenu, BBjMenuItem, and BBjCheckableMenuItem elements. To style the BBjPopupMenu versions of these elements, specify the CSS selectors like this:

.BBjPopupMenu .BBjMenuItem

{

}

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.png

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.



______________________________________________________________________________________

Copyright BASIS International Ltd. BBj®, Visual PRO/5®, PRO/5®, and BBx® are registered trademarks.