BBjMenuBar

Creation Path


BBjAPI

|

+--BBjSysGui

|

+--BBjWindow

|

+--BBjMenuBar

 

Description

The BBjMenuBar object provides methods for manipulating a GUI menu bar control.

Creation

A BBjMenuBar object is created through the following BBjTopLevelWindow methods:

Return Value

Method

BBjMenuBar

addMenuBar()

BBjMenuBar

getMenuBar()

Methods of BBjMenuBar

Return Value

Method

BBjMenu

addMenu(int ID, string title)

int

getChildCount()

BBjMenu

getMenu(int ID)

BBjMenu

getMenuAt(int index)

int

getMenuIDAt(int index)

string

getMenuString()

BBjMenu

insertMenu(int index, int ID, string title)

void

removeMenu(int ID)

void

removeMenu(BBjMenu menu)

void

removeMenuAt(int index)

Methods of BBjMenuItem inherited from BBjControl

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 BBjMenuBar defines the following style names:

.BBjMenuBar

.BBjMenuBar.bbj-disabled

Remarks

When using the BBjMenuBar object, it is not necessary to create a default menu on the form. Simply create a window without a menu bar and then use the BBjTopLevelWindow.addMenuBar() method to add the menu bar.

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

All index values are zero-based.

BBjMenuBar: The BBjMenuBar is the top-level bar that fits across the top of the window. BBjMenus are added to the menu bar. Each Top Level window can have one BBjMenuBar.

BBjMenu: A BBjMenu object is a menu that can have menu items and submenus within it. 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 BBjMenus. The BBjMenuItem can be checkable. In this case a checkbox will appear next to the menu item's title. When the item is selected, the check will toggle.

The image below (Figure 1) illustrates the three different menu objects:

menu.png

Constants inherited from BBjControl

Example

REM Add a menu bar/menu/menu items to a Window

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=10
Y=10
WIDTH=200
HEIGHT=200
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 the menu bar
myMenuBar!=myWindow!.addMenuBar()

REM Add a menu to the menu bar
myMenu!=myMenuBar!.addMenu(-100,"&First")

REM Add menu items to the menu
myMenu!.addMenuItem(-101,"&Sub Item 01")
myMenu!.addMenuItem(-102,"S&ub Item 02")

REM Add a sub menu to the menu
mySubMenu!=myMenu!.addMenu(-200,"Su&b Item 03")

REM Add menu items to the sub menu
mySubMenu!.addMenuItem(-201,"Sub Sub Item 04")
mySubMenu!.addMenuItem(-202,"Sub Sub Item 05")

REM Add a seperator the sub menu
mySubMenu!.addSeparator()
mySubMenu!.addMenuItem(-203,"Sub Sub Item 06")
mySubMenu!.addMenuItem(-204,"Sub Sub Item 07")

REM Register the CALLBACK routines
CALLBACK(ON_CLOSE,APP_CLOSE,mySysGui!.getContext())

REM Process Events
PROCESS_EVENTS

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

See Also

BBjAPI

BBjSysGui

BBjWindow

SETMENU Mnemonic - Set or Replace Menu

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.