Class TCastleOnScreenMenu
Unit
CastleOnScreenMenu
Declaration
type TCastleOnScreenMenu = class(TCastleUserInterfaceFont)
Description
On-screen menu, with all menu items displayed on the screen, one under another. Often used for game "main menu" screen. Normal tools may prefer to use the normal menu bar (TCastleWindowBase.MainMenu, or normal Lazarus main menu) instead of this.
Each clickable menu item should be a TCastleOnScreenMenuItem descendant, and should be added to the MenuItems list. The TCastleOnScreenMenuItem.Menu should be set to point back to the menu instance, this way it can look at menu's properties like desired color and font. You can also add other controls to MenuItems – it's a simple TCastleVerticalGroup, all the controls are just displayed one under another. E.g. you can add TCastleLabel to have non-clickable text, or you can add TCastleUserInterface with explicit TCastleUserInterface.Height to add some vertical space.
Hierarchy
Overview
Fields
 |
nested const DefaultMenuKeyNextItem = keyArrowDown; |
 |
nested const DefaultMenuKeyPreviousItem = keyArrowUp; |
 |
nested const DefaultMenuKeySelectItem = keyEnter; |
 |
nested const DefaultCurrentItemBorderColor1: TCastleColor = (Data: (1.0, 1.0, 1.0, 1.0)) ; |
 |
nested const DefaultCurrentItemBorderColor2: TCastleColor = (Data: (0.5, 0.5, 0.5, 1.0)) ; |
 |
nested const DefaultCurrentItemColor : TCastleColor = (Data: (1.0, 1.0, 0.0, 1.0)) ; |
 |
nested const DefaultNonCurrentItemColor : TCastleColor = (Data: (1.0, 1.0, 1.0, 1.0)) ; |
 |
nested const DefaultNonFocusableItemColor : TCastleColor = (Data: (0.75, 0.75, 0.75, 1.0)) ; |
 |
nested const DefaultRegularSpaceBetweenItems = 10; |
 |
nested const DefaultBackgroundOpacityNotFocused = 0.4; |
 |
nested const DefaultBackgroundOpacityFocused = 0.7; |
Methods
Properties
Description
Fields
 |
nested const DefaultMenuKeyPreviousItem = keyArrowUp; |
|
|
 |
nested const DefaultMenuKeySelectItem = keyEnter; |
|
|
 |
nested const DefaultCurrentItemBorderColor1: TCastleColor = (Data: (1.0, 1.0, 1.0, 1.0)) ; |
|
|
 |
nested const DefaultCurrentItemBorderColor2: TCastleColor = (Data: (0.5, 0.5, 0.5, 1.0)) ; |
|
|
 |
nested const DefaultCurrentItemColor : TCastleColor = (Data: (1.0, 1.0, 0.0, 1.0)) ; |
|
|
 |
nested const DefaultNonCurrentItemColor : TCastleColor = (Data: (1.0, 1.0, 1.0, 1.0)) ; |
|
|
 |
nested const DefaultNonFocusableItemColor : TCastleColor = (Data: (0.75, 0.75, 0.75, 1.0)) ; |
|
|
 |
nested const DefaultRegularSpaceBetweenItems = 10; |
|
|
 |
nested const DefaultBackgroundOpacityNotFocused = 0.4; |
|
|
 |
nested const DefaultBackgroundOpacityFocused = 0.7; |
|
|
Methods
 |
procedure BeforeSizing; override; |
|
|
 |
constructor Create(AOwner: TComponent); override; |
|
|
 |
destructor Destroy; override; |
|
|
 |
procedure Add(const S: string); |
|
|
 |
procedure Add(const S: string; const ItemOnClick: TNotifyEvent); |
|
|
 |
procedure NextItem; |
|
Change CurrentItem to next or previous. Usually you will just let this class call it internally (from Motion, KeyDown etc.) and will not need to call it yourself.
Parameters
- UserAction
- Determines should we play a sound when user changes menu items.
|
 |
procedure PreviousItem; |
|
|
 |
function CapturesEventsAtPosition(const Position: TVector2): boolean; override; |
|
|
 |
procedure Render; override; |
|
|
 |
procedure Update(const SecondsPassed: Single; var HandleInput: boolean); override; |
|
|
 |
function AllowSuspendForInput: boolean; override; |
|
|
 |
procedure Click; virtual; deprecated 'use TCastleMenuButton and it''s OnClick event'; |
|
Warning: this symbol is deprecated: use TCastleMenuButton and it's OnClick event
Called when user will select CurrentItem, either with mouse or with keyboard.
|
 |
procedure CurrentItemSelected; virtual; deprecated 'use TCastleMenuButton and it''s OnClick event'; |
|
Warning: this symbol is deprecated: use TCastleMenuButton and it's OnClick event
Deprecated name for Click.
|
 |
procedure CurrentItemChangedByUser; virtual; |
|
Called when CurrentItem changed by a user action (keyboard press, mouse move or click or something like that).
|
 |
function SpaceBetweenItems(const NextItemIndex: Cardinal): Single; virtual; deprecated 'ignored now; if you want to add extra space, add TCastleUserInterface with explicit Height to MenuItems'; |
|
Warning: this symbol is deprecated: ignored now; if you want to add extra space, add TCastleUserInterface with explicit Height to MenuItems
Return the space needed before NextItemIndex. This will be a space between NextItemIndex - 1 and NextItemIndex (this method will not be called for NextItemIndex = 0).
Default implementation in this class simply returns RegularSpaceBetweenItems always.
Note that this is used only at RecalculateSize call. So when some variable affecting the implementation of this changes, you should call RecalculateSize again.
|
Properties
 |
property CurrentItem: Integer read GetCurrentItem write SetCurrentItem; |
|
Currently selected child index. This is always some number between 0 and MenuItems.ControlsCount - 1. It can also be -1 to indicate "no child is selected". When MenuItems is empty (MenuItems.ControlsCount = 0) it is always -1.
You can change it by code. Assigning here an invalid value (e.g. larger then MenuItems.ControlsCount - 1) will be automatically fixed. Also when the children change (and so ControlsCount changes), this is automatically fixed if necessary.
Changing this calls CurrentItemChanged automatically, but not CurrentItemChangedByUser.
|
 |
property NonCurrentItemColor: TCastleColor
read FNonCurrentItemColor write FNonCurrentItemColor; |
|
Label color for the non-focused but focusable child. Default value is DefaultNonCurrentItemColor
|
 |
property OnClick: TNotifyEvent read FOnClick write FOnClick; deprecated 'use Add method to add a particular menu item with it''s own click callback; or just add TCastleMenuButton and handle it''s OnClick event'; |
|
Warning: this symbol is deprecated: use Add method to add a particular menu item with it's own click callback; or just add TCastleMenuButton and handle it's OnClick event
Called when user will select CurrentItem.
See also
- Click
- Called when user will select CurrentItem, either with mouse or with keyboard.
|
 |
property AutoSizeToChildren default true; |
|
|
 |
property MenuItems: TCastleVerticalGroup read FMenuItems; |
|
Menu items, and things between menu items, should be added here.
|
 |
property DrawBackgroundRectangle: boolean
read FDrawBackgroundRectangle write FDrawBackgroundRectangle
default true; |
|
|
 |
property RegularSpaceBetweenItems: Single
read FRegularSpaceBetweenItems write SetRegularSpaceBetweenItems
default DefaultRegularSpaceBetweenItems; |
|
Additional vertical space, in pixels, between menu items.
If you want more control over it (if you want to add more/less space between some menu items), override SpaceBetweenItems method.
|
 |
property DrawFocusedBorder: boolean read FDrawFocusedBorder write FDrawFocusedBorder
default true; |
|
Draw a flashing border around the menu when we are focused.
|
 |
property CaptureAllEvents: boolean
read FCaptureAllEvents write FCaptureAllEvents default false; |
|
Should menu intercept all key/mouse input, regardless if mouse position is over our rectangle. This affects key/mouse processing (menu processes input before all controls underneath), but not drawing (controls underneath are still visible as usual).
|
Generated by PasDoc 0.16.0.