Castle Game EngineIntroduction Units Class Hierarchy Classes, Interfaces, Objects and Records Types Variables Constants Functions and Procedures Identifiers
|
Class TCastleOnScreenMenu
Unit
CastleOnScreenMenu
Declaration
type TCastleOnScreenMenu = class(TUIControlFont)
Description
On-screen menu, with all menu items displayed on the screen, one under the other. Typical for game menus. Normal tools may prefer to use the menu bar instead of this (for example TCastleWindowCustom.Menu, or normal Lazarus menu).
Each menu item can have an "accessory", for example an associated slider (from TCastleFloatSlider, any TUIControl is OK). This allows to use this menu also for settings.
Hierarchy
Overview
Fields
 |
internal const DefaultMenuKeyNextItem = K_Down; |
 |
internal const DefaultMenuKeyPreviousItem = K_Up; |
 |
internal const DefaultMenuKeySelectItem = K_Enter; |
 |
internal const DefaultCurrentItemBorderColor1: TCastleColor = (Data: (1.0, 1.0, 1.0, 1.0)) ; |
 |
internal const DefaultCurrentItemBorderColor2: TCastleColor = (Data: (0.5, 0.5, 0.5, 1.0)) ; |
 |
internal const DefaultCurrentItemColor : TCastleColor = (Data: (1.0, 1.0, 0.0, 1.0)) ; |
 |
internal const DefaultNonCurrentItemColor : TCastleColor = (Data: (1.0, 1.0, 1.0, 1.0)) ; |
 |
internal const DefaultNonFocusableItemColor : TCastleColor = (Data: (0.75, 0.75, 0.75, 1.0)) ; |
 |
internal const DefaultRegularSpaceBetweenItems = 10; |
 |
internal const DefaultBackgroundOpacityNotFocused = 0.4; |
 |
internal const DefaultBackgroundOpacityFocused = 0.7; |
Methods
Properties
Description
Fields
 |
internal const DefaultMenuKeyNextItem = K_Down; |
|
 |
internal const DefaultMenuKeyPreviousItem = K_Up; |
|
 |
internal const DefaultMenuKeySelectItem = K_Enter; |
|
 |
internal const DefaultCurrentItemBorderColor1: TCastleColor = (Data: (1.0, 1.0, 1.0, 1.0)) ; |
|
 |
internal const DefaultCurrentItemBorderColor2: TCastleColor = (Data: (0.5, 0.5, 0.5, 1.0)) ; |
|
 |
internal const DefaultCurrentItemColor : TCastleColor = (Data: (1.0, 1.0, 0.0, 1.0)) ; |
|
 |
internal const DefaultNonCurrentItemColor : TCastleColor = (Data: (1.0, 1.0, 1.0, 1.0)) ; |
|
 |
internal const DefaultNonFocusableItemColor : TCastleColor = (Data: (0.75, 0.75, 0.75, 1.0)) ; |
|
 |
internal const DefaultRegularSpaceBetweenItems = 10; |
|
 |
internal const DefaultBackgroundOpacityNotFocused = 0.4; |
|
 |
internal const DefaultBackgroundOpacityFocused = 0.7; |
|
Methods
 |
procedure UIScaleChanged; override; |
|
 |
function ControlFocusable(const C: TUIControl): boolean; virtual; |
Decide whether a children control is focusable or not. This is used to decide should we show an "active frame" around this item in the menu. It does not determine whether the mouse events actually reach the child control.
By default, a single TCastleLabel (without children) is considered "not focusable". Everything else is focusable.
|
 |
constructor Create(AOwner: TComponent); override; |
|
 |
destructor Destroy; override; |
|
 |
procedure Add(const S: string); |
|
 |
procedure Add(const S: string; const Accessory: TUIControl); |
|
 |
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; |
|
 |
procedure RecalculateSize; |
Calculate final positions, sizes of menu items on the screen. Usually this is called automatically when necessary.
|
 |
procedure Resize; override; |
|
 |
function CapturesEventsAtPosition(const Position: TVector2): boolean; override; |
|
 |
procedure Render; override; |
|
 |
function Motion(const Event: TInputMotion): boolean; 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): Cardinal; virtual; |
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 ControlsCount - 1 . It can also be -1 to indicate "no child is selected". When there are no controls (ControlsCount = 0 ) it is always -1 .
You can change it by code. Assigning here an invalid value (e.g. larger then 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 CurrentItemBorderColor1: TCastleColor
read FCurrentItemBorderColor1 write FCurrentItemBorderColor1; |
1st color of the border to display around focused child. Default value is DefaultCurrentItemBorderColor1
|
 |
property CurrentItemBorderColor2: TCastleColor
read FCurrentItemBorderColor2 write FCurrentItemBorderColor2; |
2nd color of the border to display around focused child. Default value is DefaultCurrentItemBorderColor2
|
 |
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 DrawBackgroundRectangle: boolean
read FDrawBackgroundRectangle write FDrawBackgroundRectangle
default true; |
|
 |
property RegularSpaceBetweenItems: Cardinal
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.15.0.
|