BBjMenuButton

Creation Path


BBjAPI

|

+--BBjSysGui

|

+--BBjWindow

|

+--BBjMenuButton

 

Description

In BBj 7.0 and higher, the BBjMenuButton object provides methods for manipulating a rollover-style button control with an optional dropdown menu.

Implemented Interfaces

In BBj 7.0 and higher: DropTarget, Injectable, TextAlignable

In BBj 15.0 and higher: DragSource, Focusable, TabTraversable

Creation

A BBjMenuButton object is created through the following BBjWindow methods:

Return Value

Method

BBjMenuButton

addMenuButton(int ID, int x, int y, int width, int height, string title)

BBjMenuButton

addMenuButton(int ID, int x, int y, int width, int height, string title, string flags)

Methods of BBjMenuButton

Return Value

Method

BBjPopupMenu

addDropdownMenu()

void

clearImageSize()

boolean

getBeep()

boolean

getDisableOnClick()

int

getDropdownButtonWidth()

BBjPopupMenu

getDropdownMenu()

string

getImageFile()

int

getImageHeight()

int

getImageWidth()

boolean

isBorderPainted()

boolean

isDropdownMenuVisible()

void

removeDropdownMenu()

void

setBeep(boolean beep)

void

setBorderPainted(boolean paint)

void

setDisableOnClick(boolean disable)

void

setDropdownMenu(BBjPopupMenu dropdownMenu)

void

setDropdownMenuVisible(boolean visible)

void

setDropdownButtonWidth(int width)

void

setImage(BBjImage image)

void

setImageFile(string file)

void

setImageSize(int height, int width)

Methods of BBjMenuButton implemented for DragSource

Return Value

Method

int

getDragActions()

string

getDragType()

void

setDragActions(int actions)

void

setDragType(string type)

Methods of BBjMenuButton implemented for DropTarget

Return Value

Method

int

getDropActions()

void

setDropActions(int actions)

BBjVector

getDropTypes()

void

setDropTypes(BBjVector types!)

Methods of BBjMenuButton implemented for Focusable

Return Value

Method

boolean

isFocusable()

void

setFocusable(boolean p_focus)

Methods of BBjButton implemented for Injectable

Return Value

Method

string

getInjectString()

void

setInjectString(string injectString)

Methods of BBjMenuButton implemented for TabTraversable

Return Value

Method

boolean

isTabTraversable()

void

setTabTraversable(boolean trav)

Methods of BBjMenuButton implemented for TextAlignable

Return Value

Method

int

getAlignment()

void

setAlignment(int p_align)

Methods of BBjMenuButton inherited from BBjControl

Events

Callback Code

Object-oriented Event

Read Record Event

Code

ON_BUTTON_PUSH

BBjButtonPushEvent

Push Button Event

B

ON_DROP_TARGET_DROP

BBjDropTargetDropEvent

Drop Target Drop Event

D

ON_FORM_VALIDATION

BBjFormValidationEvent

Form Validation Event

V

ON_GAINED_FOCUS

BBjGainedFocusEvent

Control Focus Gained/Lost Event

f

ON_LOST_FOCUS

BBjLostFocusEvent

Control Focus Gained/Lost Event

f

ON_MOUSE_ENTER

BBjMouseEnterEvent

Mouse Enter/Exit Event

E

ON_MOUSE_EXIT

BBjMouseExitEvent

Mouse Enter/Exit Event

E

ON_POPUP_REQUEST

BBjPopupRequestEvent

Popup Request Event

r

ON_RIGHT_MOUSE_DOWN

BBjRightMouseDownEvent

Right Mouse Button Down 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 BBjMenuButton can be used in several different ways. With a dropdown menu, it combines a button and menu in a single control. If no menu is defined, it acts as a rollover button that has a more noticeable appearance as the user hovers over it. Here's a very basic sample program, showing just a few of these variations:

sysgui = unt

open (sysgui)"X0"

sysgui! = bbjapi().getSysGui()

image$ = "com/basis/bbj/images/basis-b.gif"

image! = sysgui!.getImageManager().loadImageFromServerJar(image$)

window! = sysgui!.addWindow(50,50,200,200,"BBjMenuButton",$00090003$)

window!.setCallback(window!.ON_CLOSE,"eoj")

menubutton1! = window!.addMenuButton(101,25,25,150,50,"MenuButton",$$)

menubutton1!.setImage(image!)

menubutton2! = window!.addMenuButton(102,25,100,150,50,"MenuButton",$4000$)

menubutton2!.setImage(image!)

dropdownMenu! = sysgui!.addPopupMenu()

dropdownItem1! = dropdownMenu!.addMenuItem(-201,"Dropdown Item 1")

dropdownItem2! = dropdownMenu!.addMenuItem(-202,"Dropdown Item 2")

menuButton2!.setDropdownMenu(dropdownMenu!)

process_events

eoj:

release

With the default CSS styles, it looks like this:

The BBjMenuButton defines the following style names:

.BBjMenuButton (the top level control)

.BBjMenuButton-button (the main button area)

.BBjMenuButton-button-down-hovering (the main button area when pressed by the user)

.BBjMenuButton-button-up-hovering (the main button area when the user is hovering over it)

.BBjMenuButton-dropdown (the dropdown button on the right edge -- if the button has a dropdown)

.BBjMenuButton-dropdown-down-hovering (the dropdown button area when pressed by the user)

.BBjMenuButton-dropdown-up-hovering (the dropdown button area when the user is hovering over it)

.BBjMenuButton-dropdown-image (the dropdown button image)

.BBjMenuButton-menu (the dropdown menu)

.BBjMenuButton.bbj-bordered (the BBjMenuButton was created with a permanent border)

.BBjMenuButton.bbj-disabled (the BBjMenuButton is disabled)

.BBjMenuButton.bbj-focused (the BBjMenuButton is focused)

.BBjMenuButton.bbj-dropdown (the BBjMenuButton has a dropdown menu)

Remarks

By default, menu buttons are not focusable or tab traversable. In BBj 15 and higher, applications that require all menu buttons to be focusable can set the MENUBUTTON_FOCUSABLE !COMPAT setting to TRUE. Applications that require all menu buttons to be tab traversable can set the MENUBUTTON_TAB_TRAVERSABLE !COMPAT setting to TRUE.

 
Mobile touch-oriented browsers (e.g. Mobile Safari in iOS, Chrome in Android) wait for 300 milliseconds after the user taps an element before generating a click event. This delay makes applications feel sluggish when the user tries to click on multiple buttons in rapid sequence, a process that can be common in applications like phone dialers. When the FAST_TOUCH_CLICK !OPTIONS setting is set to TRUE, BUI menu buttons on iOS and Android report ON_BUTTON_PUSH immediately when the user touches and releases their finger from a button. This improves the responsiveness for those events, but introduces some side effects that the developer should be aware of. Because BUI is handling touch events on these buttons, normal double-tap and pinch-zoom gestures don't work. And because BUI is reporting the ON_BUTTON_PUSH event immediately, it appears in the event stream before the button reports gaining focus. Some applications are sensitive to precise sequence of events.

Constants inherited from BBjControl

Example

REM Create a BBjMenuButton

REM Obtain the instance of the BBjAPI object
LET myAPI!=BBjAPI()

REM Open the SysGui device
SYSGUI=UNT
OPEN (SYSGUI)"X0"
DIM EVENT$:TMPL(SYSGUI)

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 BBjMenuButtons
menuButton1! = myWindow!.addMenuButton(101,0,0,100,22,"MenuButton1")
menuButton2! = myWindow!.addMenuButton(102,100,0,100,22,"MenuButton2")

REM Create a dropdown menu
myDropdownMenu!=mySysGui!.addPopupMenu()
myDropdownItem1! = myDropdownMenu!.addMenuItem(-201,"Dropdown Item 1")
myDropdownItem2! = myDropdownMenu!.addMenuItem(-202,"Dropdown Item 2")

REM Associate dropdown menu with the buttons
menuButton1!.setDropdownMenu(myDropdownMenu!)
menuButton2!.setDropdownMenu(myDropdownMenu!)

REM Create a popup menu
myPopupMenu!=mySysGui!.addPopupMenu()
myPopupItem1! = myPopupMenu!.addMenuItem(-301,"Popup Item 1")
myPopupItem2! = myPopupMenu!.addMenuItem(-302,"Popup Item 2")

REM Associate popup menu with the buttons
menuButton1!.setPopupMenu(myPopupMenu!)
menuButton2!.setPopupMenu(myPopupMenu!)

REM Register the CALLBACK routines
CALLBACK(ON_BUTTON_PUSH,MenuButton1,mySysGui!.getContext(),MenuButton1!.getID())
CALLBACK(ON_BUTTON_PUSH,MenuButton2,mySysGui!.getContext(),MenuButton2!.getID())
CALLBACK(ON_POPUP_ITEM_SELECT,DropdownItem1,myDropdownMenu!.getID(),myDropdownItem1!.getID())
CALLBACK(ON_POPUP_ITEM_SELECT,DropdownItem2,myDropdownMenu!.getID(),myDropdownItem2!.getID())
CALLBACK(ON_POPUP_ITEM_SELECT,PopupItem1,myPopupMenu!.getID(),myPopupItem1!.getID())
CALLBACK(ON_POPUP_ITEM_SELECT,PopupItem2,myPopupMenu!.getID(),myPopupItem2!.getID())
CALLBACK(ON_CLOSE,APP_CLOSE,mySysGui!.getContext())

REM Process Events
PROCESS_EVENTS

REM Callback routine invoked when the user clicks the button
MenuButton1:
event! = mySysGui!.getLastEvent()
event$ = mySysGui!.getLastEventString()
i = msgbox("MenuButton1 was clicked")
return

REM Callback routine invoked when the user clicks the button
MenuButton2:
event! = mySysGui!.getLastEvent()
event$ = mySysGui!.getLastEventString()
i = msgbox("MenuButton2 was clicked")
return

REM Callback routine invoked when the user selects the first dropdown item
DropdownItem1:
event! = mySysGui!.getLastEvent()
event$ = mySysGui!.getLastEventString()
i = msgbox("Dropdown Item 1 was selected on "+event!.getControl().getText())
return

REM Callback routine invoked when the user selects the second dropdown item
DropdownItem2:
event! = mySysGui!.getLastEvent()
event$ = mySysGui!.getLastEventString()
i = msgbox("Dropdown Item 2 was selected on "+event!.getControl().getText())
return

REM Callback routine invoked when the user selects the first popup item
PopupItem1:
event! = mySysGui!.getLastEvent()
event$ = mySysGui!.getLastEventString()
i = msgbox("Popup Item 1 was selected on "+event!.getControl().getText())
return

REM Callback routine invoked when the user selects the second popup item
PopupItem2:
event! = mySysGui!.getLastEvent()
event$ = mySysGui!.getLastEventString()
i = msgbox("Popup Item 2 was selected on "+event!.getControl().getText())
return

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

See Also

BBjAPI

BBjSysGui

BBjWindow

BUTTON Mnemonic - Create a Push Button Control

CALLBACK Verb - Register BBj Subroutine

DropTarget

Injectable

TextAlignable

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.