Castle Game Engine: CastleWindow: Class TMenuItem

# Class TMenuItem
Description | Hierarchy | Fields | Methods | Properties
## Unit CastleWindow ## Declaration `type TMenuItem = class(TMenuEntryWithCaption)` ## Description TMenuEntry that is a simple, clickable menu item. User expects that something will happend when he clicks on `TMenuItem`. You can also specify key shortcuts for this menu item. ## Hierarchy TObject TMenuEntry TMenuEntryWithCaption TMenuItem ## Overview ### Methods
| `function DoClick: boolean; virtual;`
| `function KeyString(out S: string): boolean;`
| `function KeyMatches(const AKey: TKey; const ACharKey: char; const AModifiers: TModifierKeys): boolean;`
| `function CaptionWithKey: string;`
| `constructor Create(const ACaption: String; AIntData: Integer);`
| `constructor Create(const ACaption: String; AIntData: Integer; ACharKey: char);`
| `constructor Create(const ACaption: String; AIntData: Integer; AKey: TKey);`
| `destructor Destroy; override;`
### Properties
| `property IntData: Integer read FIntData write FIntData;`
| `property SmallId: Integer read FSmallId;`
| `property CharKey: char read FCharKey write FCharKey default #0;`
| `property Key: TKey read FKey write FKey default K_None;`
| `property Modifiers: TModifierKeys read FModifiers write FModifiers;`
## Description ### Methods
| `function DoClick: boolean; virtual;`
Called when this menu item will be choosen by user (by clicking, or pressing the matching key shortcut). You can override this and return true if you handled the event. If this will return false, CastleWindow will call EventMenuClick (OnMenuClick). When entering this method, current OpenGL context is set to the context of the window that the clicked menu belongs to. Default implementation of this method in this class always returns false.
| `function KeyString(out S: string): boolean;`
Returns as S the string that describes key shortcut (CharKey, Key, Modifiers) and then returns true. If both CharKey = #0 and Key = K_None then returns false and S is undefined.
| `function KeyMatches(const AKey: TKey; const ACharKey: char; const AModifiers: TModifierKeys): boolean;`
| `function CaptionWithKey: string;`
Caption with optional key description (returned by KeyString) appended.
| `constructor Create(const ACaption: String; AIntData: Integer);`
| `constructor Create(const ACaption: String; AIntData: Integer; ACharKey: char);`
| `constructor Create(const ACaption: String; AIntData: Integer; AKey: TKey);`
| `destructor Destroy; override;`
### Properties
| `property IntData: Integer read FIntData write FIntData;`
An integer value, for any purpose you want. Useful to identify this item in TCastleWindowCustom.OnMenuClick callback.
| `property SmallId: Integer read FSmallId;`
Unique small identifier of this menu item. This is initialized at creation of this object, to be unique among all currently existing (created and not destroyed) TMenuItem instances. The intention is that this `SmallId` should be the smallest possible value >= 0. So it's not something like PtrUInt(Self). This may be useful when you're constructing a menu using some API — you usually want to identify your menu item by some unique id and you want this id to be small (e.g. under WinAPI menu item's id must fit in 16 bit integer). ###### See also MenuItemFromSmallId Search for menu item with given SmallId.
| `property CharKey: char read FCharKey write FCharKey default #0;`
Key shortcut for this menu item. When user presses indicated Key (if it's not K_None) or `CharKey` (if it's not #0) then DoClick will be called (which results in TCastleWindowCustom.EventMenuClick, and TCastleWindowCustom.OnMenuClick, if DoClick returns false). Handling of menu key shortcuts is completely within the CastleWindow (usually, it's even done by the underlying backend like GTK or WinAPI). You will not get EventPress (OnPress) messages for keypresses that translate to menu clicks. Although TCastleWindowCustom.Pressed.Keys will be still appropriately updated. Note that Caption of this object should not contain description of Key or `CharKey`. The backend will automatically show the key description in an appropriate way. You should use at most one of these properties, not both. So either use Key or `CharKey`, and leave the other one at default value (Key = K_None, `CharKey` = #0). Note that `CharKey` = #8 (CharBackSpace = CtrlH) or `CharKey` = #9 (CharTab = CtrlI) or `CharKey` = #13 (CharEnter = CtrlM) are interpreted to mean the combination of letter with Ctrl modfier. They do not mean the backspace or tab or enter keys. If you want to have backspace/tab/enter keys to activate the menu item, use Key = K_BackSpace, Key = K_Tab or Key = K_Enter. TODO: for now, this must be assigned before adding this menu item to parent (actually, before the parent menu is added to window MainMenu) to work reliably. Don't change this property afterwards. Usually, you will set this property by an argument to the constructor.
| `property Key: TKey read FKey write FKey default K_None;`
| `property Modifiers: TModifierKeys read FModifiers write FModifiers;`
`Modifiers` (shift, ctrl and such) required to activate this menu item. These have to be pressed along with Key or CharKey. Note that CharKey may already indicate some `modifiers`, if it's one of the CtrlA ... CtrlZ then the Ctrl key is required and if it's an uppercase letter then the Shift key is required. There's no need to include this modifier in this property then. TODO: for now, this must be assigned before adding this menu item to parent (actually, before the parent menu is added to window MainMenu) to work reliably. Don't change this property afterwards.
Generated by PasDoc 0.13.0 on 2015-06-15 04:43:13