xHarbour Reference Documentation > Class Reference (textmode) |
|
|
MenuItem()
Creates a new MenuItem object.
Syntax
MenuItem():new( <cCaption> , ;
<bBlock>|<oPopup>, ;
[<nShortcut>] , ;
[<cMessage>] , ;
[<nID>] ) --> oMenuItem
Arguments
- <cCaption>
- This is a character string displayed as the caption of a menu item. An
accelerator key can be marked in the caption string by prefixing it with
an ampersand (&). A menu item is then selected when a user presses the
prefixed character. It is assigned to the instance variable :caption.
Instead of a character string, the #define constant MENU_SEPARATOR from Button.ch
can be passed for <cCaption>. This creates a horizonal separator line to distinguish
logical groups of menu items within a Popup menu.
- <bBlock>
- This is the menu activation code block which calls the subroutine after
a user has selected the menu item. It is assigned to the instance variable :data.
- <oPopup>
- Instead of a code block, a Popup() menu object can be specified as
second parameter. In this case, a sub-menu is opened when the menu item is selected.
This allows for programming menu systems with nested sub-menus.
- <nShortCut>
- Optionally, a numeric Inkey() code can be passed that serves as
shortcut key for evaluating <bBlock>. It is assigned to the instance variable :shortCut.
- <cMessage>
- A character string holding a status message associated with a menu item can optionally
be specified. It is displayed in the message row when a TopBarMenu() is
activated. <cMessage> is assigned to the instance variable :message.
- <nID>
- An optional numeric value can be passed which is stored in the instance variable :ID.
If this parameter is used, it should be a unique value for each MenuItem object created.
Return
Function MenuItem() creates a new MenuItem object, and method :new() initializes the object.
Description
The MenuItem() class is a utility class whose objects are only used in conjunction with
TopBarMenu() and/or Popup() objects. A MenuItem() object holds
in its instance variables all information required to display a single menu item within a
top bar menu or a pop-up menu, and to branch program control after a user has selected
a menu item.
Note: refer to the example of the TopBarMenu() class for using MenuItem() objects.
Instance variables
- :caption
- Caption string of the menu item.
- :cargo
- Instance variable for user-defined purposes.
- :checked
- Logical value indicating a check mark.
- :data
- Menu selection code block or Popu menu object.
- :enabled
- Logical value indicating if a menu item can be selected.
- :id
- Numeric identifier for a menu item.
- :message
- Character string describing a menu item.
- :shortCut
- Numeric shortcut key.
- :style
- Character string for check mark and sub-menus
Methods
- :isPopUp() --> lIsPopup
- Checks if the menu item opens a sub-menu.
Info
Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe