Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.
ON BAR
, ON PAD
, ON SELECTION BAR
, ON SELECTION MENU
, ON SELECTION PAD
, ON SELECTION POPUP
These commands are the key to making your menus do something. The DEFINE commands set up the menus and the ACTIVATE commands turn them on, but without the ON and ON SELECTION commands, not much happens after that.
The ON BAR
and ON PAD
commands let one menu component activate another component. The ON SELECTION commands are much broader—they let you specify anything at all to happen when a particular item is chosen.
ON BAR nBar OF PopupName [ ACTIVATE POPUP SubPopupName |
ACTIVATE MENU SubMenuName ]
ON PAD PadName OF MenuName [ ACTIVATE POPUP PopupName |
ACTIVATE MENU SubMenuName ]
With hierarchical menus, choosing a pad of a menu generally opens a popup. Choosing a bar from a menu popup sometimes leads to another popup. That’s what ON BAR
and ON PAD
are about. When a menu bar calls another popup, FoxPro takes care of putting in the little arrow that indicates a nested menu.
We’ve never used the ACTIVATE MENU
alternative here and it violates every menu standard we know of, so we don’t plan to start using it anytime soon.
* From the system menu:
ON PAD _MSM_FILE OF _MSYSMENU ACTIVATE POPUP _MFILE
ON SELECTION BAR nBar OF PopupName [ Command ]
ON SELECTION MENU MenuName | ALL [ Command ]
ON SELECTION PAD PadName OF MenuName [ Command ]
ON SELECTION POPUP PopupName | ALL [ Command ]
The MENU and POPUP versions of these propagate down one level to their contained pads and bars. You can then override those choices for individual bars and pads.
ON PAD
and ON BAR
commands take precedence over ON SELECTION BAR
and ON SELECTION PAD
. That is, if you specify both for a bar or pad, the popup or menu you specified gets activated when the bar or pad is chosen. The code specified in ON SELECTION is ignored.
USE Employee
DEFINE POPUP EmpPop ;
PROMPT FIELDS TRIM(First_Name - (" " + Last_Name))
ON SELECTION POPUP EmpPop WAIT WINDOW "You picked "+PROMPT()
Activate Menu, Activate Popup, Define Bar, Define Menu, Define Pad, Define Popup, Menus