BBjMenuButton::setDropdownMenuVisible

Description

In BBj 15.0 and higher, this BBjMenuButton method programmatically hides or shows the dropdown menu.

Syntax

Return Value

Method

void

setDropdownMenuVisible(boolean visible)

Parameters

Variable

Description

visible

Specifies whether the dropdown menu should be shown (true) or hidden (false).

Return Value

None.

Remarks

This method is ignored if the menu button does not have a dropdown menu.

Example

rem ' setDropdownMenuVisible

sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
title$ = "BBjMenuButton::setDropdownMenuVisible"
window! = sysgui!.addWindow(50,50,430,200,title$,$00090003$)
window!.setCallback(window!.ON_CLOSE,"eoj")
window!.addGroupBox(100,10,10,410,60,"Toolbar MenuButtons paint their border on rollover")
toolbarMenuButton1! = window!.addMenuButton(101,20,30,90,35,"&1",$0000$)
toolbarMenuButton2! = window!.addMenuButton(102,120,30,90,35,"&2",$0000$)
toolbarMenuButton3! = window!.addMenuButton(103,220,30,90,35,"&3",$0000$)
toolbarMenuButton4! = window!.addMenuButton(104,320,30,90,35,"&4",$0000$)
window!.addGroupBox(105,10,90,410,60,"Standalone MenuButtons always paint their border")
standaloneMenuButton1! = window!.addMenuButton(106,20,110,90,35,"&5",$4000$)
standaloneMenuButton2! = window!.addMenuButton(107,120,110,90,35,"&6",$4000$)
standaloneMenuButton3! = window!.addMenuButton(108,220,110,90,35,"&7",$0000$)
standaloneMenuButton3!.setBorderPainted(1)
standaloneMenuButton4! = window!.addMenuButton(109,320,110,90,35,"&8",$0000$)
standaloneMenuButton4!.setBorderPainted(1)
dropdownMenu! = sysgui!.addPopupMenu()
dropdownItem1! = dropdownMenu!.addMenuItem(-201,"Dropdown Item 1")
dropdownItem2! = dropdownMenu!.addMenuItem(-202,"Dropdown Item 2")
standaloneMenuButton1!.setDropdownMenu(dropdownMenu!)
standaloneMenuButton2!.setDropdownMenu(dropdownMenu!)
standaloneMenuButton3!.setDropdownMenu(dropdownMenu!)
standaloneMenuButton4!.setDropdownMenu(dropdownMenu!)
popupMenu! = sysgui!.addPopupMenu()
popupItem1! = popupMenu!.addMenuItem(-301,"Popup Item 1")
popupItem2! = popupMenu!.addMenuItem(-302,"Popup Item 2")
toolbarMenuButton1!.setPopupMenu(popupMenu!)
toolbarMenuButton2!.setPopupMenu(popupMenu!)
toolbarMenuButton3!.setPopupMenu(popupMenu!)
toolbarMenuButton4!.setPopupMenu(popupMenu!)
standaloneMenuButton1!.setPopupMenu(popupMenu!)
standaloneMenuButton2!.setPopupMenu(popupMenu!)
standaloneMenuButton3!.setPopupMenu(popupMenu!)
standaloneMenuButton4!.setPopupMenu(popupMenu!)
ToolbarMenuButton1!.setCallback(ToolBarMenuButton1!.ON_BUTTON_PUSH,"click")
ToolbarMenuButton2!.setCallback(ToolBarMenuButton2!.ON_BUTTON_PUSH,"click")
ToolbarMenuButton3!.setCallback(ToolBarMenuButton3!.ON_BUTTON_PUSH,"click")
ToolbarMenuButton4!.setCallback(ToolBarMenuButton4!.ON_BUTTON_PUSH,"click")
StandaloneMenuButton1!.setCallback(StandaloneMenuButton1!.ON_BUTTON_PUSH,"click")
StandaloneMenuButton2!.setCallback(StandaloneMenuButton2!.ON_BUTTON_PUSH,"click")
StandaloneMenuButton3!.setCallback(StandaloneMenuButton3!.ON_BUTTON_PUSH,"click")
StandaloneMenuButton4!.setCallback(StandaloneMenuButton4!.ON_BUTTON_PUSH,"click")
CALLBACK(ON_POPUP_ITEM_SELECT,PopupItem1,popupMenu!.getID(),popupItem1!.getID())
CALLBACK(ON_POPUP_ITEM_SELECT,PopupItem2,popupMenu!.getID(),popupItem2!.getID())
CALLBACK(ON_POPUP_REQUEST,request,sysgui!.getContext())
dropdownItem1!.setCallback(dropdownItem1!.ON_POPUP_ITEM_SELECT,"DropdownItem1")
dropdownItem2!.setCallback(dropdownItem2!.ON_POPUP_ITEM_SELECT,"DropdownItem2")
process_events

rem 'BBjPopupRequestEvent
request:
    event! = sysgui!.getLastEvent()
    control! = event!.getControl()
    print event!
    print control!
    print "Popup Request @ ",event!.getX(),event!.getY()
return

click:
    event! = sysgui!.getLastEvent()
    menubutton! = event!.getMenuButton()
    menubutton!.setDropdownMenuVisible(1)
return

DropdownItem1:
    event! = sysgui!.getLastEvent()
    control! = event!.getControl()
    menuitem! = event!.getMenuItem()
    event$ = sysgui!.getLastEventString()
    print event!
    print control!
    print menuitem!.getText()
    i = msgbox("Dropdown Item 1 was selected on "+event!.getControl().getText())
return

DropdownItem2:
    event! = sysgui!.getLastEvent()
    control! = event!.getControl()
    menuitem! = event!.getMenuItem()
    event$ = sysgui!.getLastEventString()
    print event!
    print control!
    print menuitem!.getText()
    i = msgbox("Dropdown Item 2 was selected on "+event!.getControl().getText())
return

PopupItem1:
    event! = sysgui!.getLastEvent()
    control! = event!.getControl()
    menuitem! = event!.getMenuItem()
    event$ = sysgui!.getLastEventString()
    print event!
    print control!
    print menuitem!.getText()
    i = msgbox("Popup Item 1 was selected on "+event!.getControl().getText())
return

PopupItem2:
    event! = sysgui!.getLastEvent()
    control! = event!.getControl()
    menuitem! = event!.getMenuItem()
    event$ = sysgui!.getLastEventString()
    print event!
    print control!
    print menuitem!.getText()
    i = msgbox("Popup Item 2 was selected on "+event!.getControl().getText())
return

event:
    event! = sysgui!.getLastEvent()
    control! = event!.getControl()
    print event!," ",control!
return

eoj:
release

See Also

BBjAPI

BBjPopupMenu

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