BBjPopupMenu::show

Description

In BBj 4.0 and higher, this method makes a popup menu visible at a specified location relative to a specified control.

Syntax

Return Value

Method

void

show(int context, int ID, int x, int y)

void

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

Parameters

Variable

Description

context

Specifies the context of the window that displays the popup menu.

ID

Specifies the control ID of the control that displays the popup menu.

control!

Specifies the control that displays the popup menu. Can use control! instead of the numeric context and control parameters.

x

Specifies the horizontal location of the upper left corner of the popup menu, relative to the specified control.

y

Specifies the vertical location of the upper left corner of the popup menu, relative to the specified control.

Return Value

None.

Remarks

None.

Example

REM Show a popup menu in response to a popup requested event

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

REM Open the SysGui device
SYSGUI=UNT
OPEN (SYSGUI)"X0"

rem ' For retrieving the event string
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=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 a button control and associate a popup menu with it.
myButton! = myWindow!.addButton(1,10,10,90,30,"OK")
myPopupMenu!=myButton!.addPopupMenu()
myItem1! = myPopupMenu!.addMenuItem(201,"Item 1")
myItem2! = myPopupMenu!.addMenuItem(202,"Item 2")

rem ' Create an inpute control and associate the same popup menu
myInputE! = myWindow!.addInputE(2,10,50,90,30)
myInputE!.setPopupMenu(myPopupMenu!)

rem ' Create an inputd control and don't associate a popup menu
myInputD! = myWindow!.addInputD(3,10,100,90,30)

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_POPUP_REQUEST,PopupRequest,mySysGui!.getContext(),myInputD!.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:
event$=mySysGui!.getLastEventString()
i = msgbox("Item 1 was selected on context "+str(event.context)+"; id="+str(event.id)+"; code="+event.code$+"; flags="+hta(event.flags$)+"; x="+str(event.x)+"; y="+str(event.y))
return

REM Callback routine invoked when the user selects the second item
Item2:
event$=mySysGui!.getLastEventString()
i = msgbox("Item 2 was selected on context "+str(event.context)+"; id="+str(event.id)+"; code="+event.code$+"; flags="+hta(event.flags$)+"; x="+str(event.x)+"; y="+str(event.y))
return

PopupRequest:
event$=mySysGui!.getLastEventString()
print "PopupRequest: Context="+str(event.context)+" id="+str(event.id)+" code="+event.code$+" flags="+hta(event.flags$)+" x="+str(event.x)+" y="+str(event.y)
myPopupMenu!.show(event.context,event.id,event.x,event.y)
return

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

See Also

BBjAPI

BBjSysGui Methods

BBjControl Methods

BBjPopupMenu

BBjMenu

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