BBjPopupMenu

Creation Path

BBjAPI > BBjSysGui > BBjPopupMenu

Description

In BBj 4.00 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

BBjSysGui::addPopupMenu()

BBjPopupMenu

BBjSysGui::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

BBjControl::addPopupMenu()

BBjPopupMenu

BBjControl::getPopupMenu()

BBjPopupMenu

BBjControl::removePopupMenu()

void

BBjControl::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()

boolean

addStyle(string styleName)

void

clearStyles()

string

getAttribute(string attribute)

BBjCheckableMenuItem

getCheckableMenuItem(int ID)

BBjCheckableMenuItem

getCheckableMenuItemAt(int index)

int

getChildCount()

string

getClientProperty(Object key)

string

getComputedStyle(string property)

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)

string

getName()

string

getStyle(string property)

BBjVector

getStyles()

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

putClientProperty(Object key, Object value)

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)

boolean

removeStyle(string styleName)

void

setAttribute(string attribute, string value)

void

setFont(BBjFont font!)

void

setMaximumRowCount(int max)

void

setName(string name)

void

setStyle(string property, string value)

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

BUI logoCSS

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

BBjControl

BBjWindow

CALLBACK Verb - Register BBj Subroutine

DWC Component: dwc-popupmenu

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