BBjControl::addPopupMenu

Description

In BBj 3.0 and higher, this method adds a popup menu to the BBjControl.

Syntax

Return Value

Method

BBjPopupMenu

addPopupMenu()

Parameters

None.

Return Value

Returns a BBjPopupMenu control.

Remarks

This method works on all controls except menus.

Example

rem 'Create a popup menu and assign it to multiple controls

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 buttons
okButton! = myWindow!.addButton(1,5,50,90,30,"OK")
cancelButton! = myWindow!.addButton(2,100,50,90,30,"Cancel")

rem 'Create a popup menu
myPopupMenu! = mySysGui!.addPopupMenu()
myItem1! = myPopupMenu!.addMenuItem(-201,"Item 1")
myItem2! = myPopupMenu!.addMenuItem(-202,"Item 2")

rem 'Associate popup menu with the buttons
okButton!.setPopupMenu(myPopupMenu!)
cancelButton!.setPopupMenu(myPopupMenu!)

rem 'Register the CALLBACK routines
CALLBACK(ON_BUTTON_PUSH,OK,mySysGui!.getContext(),okButton!.getID())
CALLBACK(ON_BUTTON_PUSH,Cancel,mySysGui!.getContext(),cancelButton!.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 clicks the button
Cancel:
    i = msgbox("Cancel Button was selected")
return

rem 'Callback routine invoked when the user selects the first item
Item1:
    event$ = mySysGui!.getLastEventString()
    i = msgbox("Popup Item 1 was selected on control ID "+str(event.id))
return

rem 'Callback routine invoked when the user selects the second item
Item2:
    event$ = mySysGui!.getLastEventString()
    i = msgbox("Popup Item 2 was selected on control ID "+str(event.id))
return

rem 'Callback routine called when the user closes the application window
APP_CLOSE:
release

See Also

BBjAPI

Object Variables

BBjPopupMenu

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