Class TCastleButton
Unit
Declaration
type TCastleButton = class(TCastleUserInterfaceFont)
Description
Clickable button. To use it, add it to a parent TCastleUserInterface (like to TCastleView), configure position, TCastleButton.Caption, and assign TCastleButton.OnClick to handle clicks.
Source: ui/castlecontrols_button.inc (line 26).
Hierarchy
- TObject
- TPersistent
- TComponent
- TCastleComponent
- TCastleUserInterface
- TCastleUserInterfaceFont
- TCastleButton
Overview
Constants
| Public | DefaultWidth = 100.0; |
| Public | DefaultHeight = 100.0; |
| Public | DefaultImageMargin = 10; |
| Public | DefaultPaddingHorizontal = 10; |
| Public | DefaultPaddingVertical = 10; |
| Public | DefaultLineSpacing = 2; |
| Public | DefaultTextAlignment = hpMiddle; |
Methods
| Protected | function GetInternalText: String; virtual; |
| Protected | procedure SetInternalText(const Value: String); virtual; |
| Protected | procedure SetName(const Value: TComponentName); override; |
| Protected | procedure TranslateProperties(const TranslatePropertyEvent: TTranslatePropertyEvent); virtual; |
| Public | destructor Destroy; override; |
| Public | procedure CustomSerialization(const SerializationProcess: TSerializationProcess); virtual; |
| Public | function PropertySections(const PropertyName: String): TPropertySections; virtual; |
| Public | procedure SetTransient; |
| Public | procedure AddNonVisualComponent(const NonVisualComponent: TComponent); |
| Public | procedure InsertNonVisualComponent(const Index: Integer; const NonVisualComponent: TComponent); |
| Public | procedure RemoveNonVisualComponent(const NonVisualComponent: TComponent); |
| Public | function NonVisualComponentsIndexOf(const NonVisualComponent: TComponent): Integer; |
| Public | function NonVisualComponentsCount: Integer; |
| Public | function NonVisualComponentsEnumerate: TNonVisualComponentsEnumerator; |
| Public | function ValueIsStreamed: Boolean; virtual; |
| Public | procedure DesignerInfo(const SList: TStrings); virtual; |
| Public | procedure DesignerWarnings(const SList: TStrings); virtual; |
| Protected | procedure Loaded; override; |
| Protected | function ContainerWidth: Cardinal; virtual; deprecated 'arrange UI using anchors, FullSize and friends; if you really need container size, use "Container.UnscaledWidth" or "Container.PixelsWidth" after checking "Container <> nil"'; |
| Protected | function ContainerHeight: Cardinal; virtual; deprecated 'arrange UI using anchors, FullSize and friends; if you really need container size, use "Container.UnscaledHeight" or "Container.PixelsHeight" after checking "Container <> nil"'; |
| Protected | function ContainerRect: TRectangle; virtual; deprecated 'arrange UI using anchors, FullSize and friends; if you really need container size, use "Container.UnscaledRect" or "Container.PixelsRect" after checking "Container <> nil"'; |
| Protected | function ContainerSizeKnown: boolean; virtual; deprecated 'arrange UI using anchors, FullSize and friends; if you really need container size, use "Container.UnscaledWidth/Height" or "Container.PixelsWidth/Height" after checking "Container <> nil"'; |
| Protected | procedure DoCursorChange; virtual; deprecated 'better override VisibleChange and watch for chCursor in Changes'; |
| Protected | procedure DefineProperties(Filer: TFiler); override; |
| Protected | procedure UIScaleChanged; virtual; |
| Protected | procedure PreferredSize(var PreferredWidth, PreferredHeight: Single); virtual; |
| Protected | procedure BeforeSizing; virtual; |
| Protected | procedure DoInternalMouseEnter; virtual; |
| Protected | procedure DoInternalMouseLeave; virtual; |
| Protected | function Theme: TCastleTheme; |
| Public | constructor Create(AOwner: TComponent); override; |
| Public | destructor Destroy; override; |
| Public | procedure CustomSerialization(const SerializationProcess: TSerializationProcess); override; |
| Public | function PropertySections(const PropertyName: String): TPropertySections; override; |
| Public | procedure DesignerInfo(const SList: TStrings); override; |
| Public | procedure DesignerWarnings(const SList: TStrings); override; |
| Public | function GetEnumerator: TEnumerator; |
| Public | procedure InternalSetContainer(const Value: TCastleContainer); virtual; |
| Public | function Press(const Event: TInputPressRelease): boolean; virtual; |
| Public | function Release(const Event: TInputPressRelease): boolean; virtual; |
| Public | function PreviewPress(const Event: TInputPressRelease): boolean; virtual; |
| Public | function PreviewRelease(const Event: TInputPressRelease): boolean; virtual; |
| Public | function Motion(const Event: TInputMotion): boolean; virtual; |
| Public | function SensorRotation(const X, Y, Z, Angle: Double; const SecondsPassed: Single): boolean; virtual; |
| Public | function SensorTranslation(const X, Y, Z, Length: Double; const SecondsPassed: Single): boolean; virtual; |
| Public | procedure Update(const SecondsPassed: Single; var HandleInput: boolean); virtual; |
| Public | procedure VisibleChange(const Changes: TCastleUserInterfaceChanges; const ChangeInitiatedByChildren: boolean = false); overload; virtual; |
| Public | function AllowSuspendForInput: boolean; virtual; |
| Public | procedure Resize; virtual; |
| Public | function ControlsCount: Integer; |
| Public | procedure InsertFront(const NewItem: TCastleUserInterface); overload; |
| Public | procedure InsertFrontIfNotExists(const NewItem: TCastleUserInterface); |
| Public | procedure InsertFront(const NewItems: TCastleUserInterfaceList); overload; |
| Public | procedure InsertBack(const NewItem: TCastleUserInterface); overload; |
| Public | procedure InsertBackIfNotExists(const NewItem: TCastleUserInterface); |
| Public | procedure InsertBack(const NewItems: TCastleUserInterfaceList); overload; |
| Public | procedure InsertControl(const Index: Integer; const NewItem: TCastleUserInterface); |
| Public | procedure RemoveControl(const Item: TCastleUserInterface); |
| Public | function IndexOfControl(const Item: TCastleUserInterface): Integer; |
| Public | procedure ClearControls; |
| Public | procedure MoveToFront; |
| Public | function CapturesEventsAtPosition(const Position: TVector2): boolean; virtual; |
| Public | procedure BeforeRender; virtual; |
| Public | procedure Render; virtual; |
| Public | procedure RenderOverChildren; virtual; |
| Public | function TooltipExists: Boolean; virtual; deprecated 'use TooltipControl to customize tooltip look'; |
| Public | procedure TooltipRender(const TooltipPosition: TVector2); virtual; deprecated 'use TooltipControl to customize tooltip look'; |
| Public | procedure GLContextOpen; virtual; |
| Public | procedure GLContextClose; virtual; |
| Public | procedure SetFocused(const Value: boolean); virtual; |
| Public | function EffectiveRect: TFloatRectangle; |
| Public | function EffectiveWidth: Single; |
| Public | function EffectiveHeight: Single; |
| Public | function EffectiveWidthForChildren: Single; |
| Public | function EffectiveHeightForChildren: Single; |
| Public | function CalculatedWidth: Cardinal; deprecated 'use EffectiveWidth'; |
| Public | function CalculatedHeight: Cardinal; deprecated 'use EffectiveHeight'; |
| Public | function CalculatedRect: TRectangle; deprecated 'use EffectiveRect'; |
| Public | function RenderRect: TFloatRectangle; |
| Public | function RenderRectWithBorder: TFloatRectangle; |
| Public | function ScreenRect: TRectangle; deprecated 'use RenderRect'; |
| Public | function ContainerToLocalPosition(ContainerPosition: TVector2; const ContainerPositionScaled: Boolean = true): TVector2; |
| Public | function LocalToContainerPosition(const LocalPosition: TVector2; const ContainerPositionScaled: Boolean = true): TVector2; |
| Public | function ParentRect: TFloatRectangle; |
| Public | procedure Anchor(const AHorizontalAnchor: THorizontalPosition; const TranslationX: Single = 0); overload; |
| Public | procedure Anchor( const AHorizontalAnchorSelf, AHorizontalAnchorParent: THorizontalPosition; const TranslationX: Single = 0); overload; |
| Public | procedure Anchor(const AVerticalAnchor: TVerticalPosition; const TranslationY: Single = 0); overload; |
| Public | procedure Anchor( const AVerticalAnchorSelf, AVerticalAnchorParent: TVerticalPosition; const TranslationY: Single = 0); overload; |
| Public | procedure AlignHorizontal( const ControlPosition: TPositionRelative = prMiddle; const ContainerPosition: TPositionRelative = prMiddle; const X: Single = 0); deprecated 'use Anchor'; |
| Public | procedure Align( const ControlPosition: THorizontalPosition; const ContainerPosition: THorizontalPosition; const X: Single = 0); overload; deprecated 'use Anchor'; |
| Public | procedure AlignVertical( const ControlPosition: TPositionRelative = prMiddle; const ContainerPosition: TPositionRelative = prMiddle; const Y: Single = 0); deprecated 'use Anchor'; |
| Public | procedure Align( const ControlPosition: TVerticalPosition; const ContainerPosition: TVerticalPosition; const Y: Single = 0); overload; deprecated 'use Anchor'; |
| Public | procedure Center; deprecated 'use Anchor(hpMiddle); Anchor(vpMiddle); to reliably center the control'; |
| Public | function UIScale: Single; virtual; |
| Public | procedure EditorAllowResize(out ResizeWidth, ResizeHeight: Boolean; out Reason: String); virtual; |
| Public | function EffectiveFullSize: Boolean; |
| Protected | procedure InternalSetTooltipExists(const Value: Boolean); override; |
| Protected | procedure UIScaleChanged; override; |
| Protected | procedure Notification(AComponent: TComponent; Operation: TOperation); override; |
| Public | constructor Create(AOwner: TComponent); override; |
| Public | destructor Destroy; override; |
| Public | function TooltipExists: boolean; override; |
| Public | procedure TooltipRender(const TooltipPosition: TVector2); override; |
| Public | procedure Render; override; |
| Public | function PropertySections(const PropertyName: String): TPropertySections; override; |
| Public | procedure AssignFont(const Source: TCastleUserInterfaceFont); |
| Public | function Font: TCastleAbstractFont; |
| Public | procedure CheckFontChanged; |
| Public | procedure FontChanged; virtual; |
| Protected | procedure SetPressed(const Value: boolean); virtual; |
| Protected | procedure UIScaleChanged; override; |
| Protected | procedure PreferredSize(var PreferredWidth, PreferredHeight: Single); override; |
| Protected | function GetInternalText: String; override; |
| Protected | procedure SetInternalText(const Value: String); override; |
| Protected | procedure TranslateProperties(const TranslatePropertyEvent: TTranslatePropertyEvent); override; |
| Public | constructor Create(AOwner: TComponent); override; |
| Public | destructor Destroy; override; |
| Public | procedure Render; override; |
| Public | function Press(const Event: TInputPressRelease): boolean; override; |
| Public | function Release(const Event: TInputPressRelease): boolean; override; |
| Public | function Motion(const Event: TInputMotion): boolean; override; |
| Public | procedure FontChanged; override; |
| Public | procedure Update(const SecondsPassed: Single; var HandleInput: boolean); override; |
| Public | procedure VisibleChange(const Changes: TCastleUserInterfaceChanges; const ChangeInitiatedByChildren: boolean = false); override; |
| Public | procedure EditorAllowResize(out ResizeWidth, ResizeHeight: Boolean; out Reason: String); override; |
| Public | function PropertySections(const PropertyName: String): TPropertySections; override; |
| Public | procedure DoClick; virtual; |
| Public | procedure SetFocused(const Value: boolean); override; |
Properties
| Public | property NonVisualComponents [const Index: Integer]: TComponent read GetNonVisualComponents; |
| Public | property IsLoading: Boolean read FIsLoading; |
| Public | property OnVisibleChange: TCastleUserInterfaceChangeEvent
read FOnVisibleChange write FOnVisibleChange; |
| Public | property Container: TCastleContainer read FContainer; |
| Public | property OnCursorChange: TNotifyEvent
read FOnCursorChange write FOnCursorChange; deprecated 'use OnVisibleChange (or override VisibleChange) and watch for Changes that include chCursor'; |
| Public | property ExclusiveEvents: boolean
read FExclusiveEvents write FExclusiveEvents default true; deprecated 'do not use this; supporting this property was complicated and had no real benefit; everything now works as if ExclusiveEvents=true, always'; |
| Public | property Controls [const Index: Integer]: TCastleUserInterface read GetControls write SetControls; |
| Public | property GetExists: Boolean read FExists; deprecated 'use Exists'; |
| Public | property GLInitialized: boolean read FGLInitialized default false; |
| Public | property Focused: boolean read FFocused write SetFocused; |
| Public | property Parent: TCastleUserInterface read FParent ; |
| Public | property FloatWidth: Single read FWidth write SetWidth stored false; deprecated 'use Width'; |
| Public | property FloatHeight: Single read FHeight write SetHeight stored false; deprecated 'use Height'; |
| Public | property AnchorDelta: TVector2 read FTranslation write SetTranslation; deprecated 'use Translation'; |
| Public | property Translation: TVector2 read FTranslation write SetTranslation; |
| Public | property KeepInFront: boolean read FKeepInFront write FKeepInFront
default false; |
| Public | property BorderColor: TCastleColor read FBorderColor write SetBorderColor; |
| Public | property HasHorizontalAnchor: boolean
read FHasHorizontalAnchor write FHasHorizontalAnchor stored false; deprecated 'this property does not do anything anymore, anchors are always active'; |
| Public | property HasVerticalAnchor: boolean
read FHasVerticalAnchor write FHasVerticalAnchor stored false; deprecated 'this property does not do anything anymore, anchors are always active'; |
| Public | property HorizontalAnchorDelta: Single
read GetHorizontalAnchorDelta write SetHorizontalAnchorDelta default 0; deprecated 'use Translation.X'; |
| Public | property VerticalAnchorDelta: Single
read GetVerticalAnchorDelta write SetVerticalAnchorDelta default 0; deprecated 'use Translation.Y'; |
| Public | property Visible: Boolean read FVisible; |
| Public | property EnableUIScaling: boolean
read FEnableUIScaling write SetEnableUIScaling default true; |
| Public | property CapturesEvents: boolean read FCapturesEvents write FCapturesEvents
default true; |
| Public | property OnInternalMouseEnter: TUiNotifyEvent
read FOnInternalMouseEnter write FOnInternalMouseEnter; |
| Public | property OnInternalMouseLeave: TUiNotifyEvent
read FOnInternalMouseLeave write FOnInternalMouseLeave; |
| Published | property Cursor: TMouseCursor read FCursor write SetCursor default mcDefault; |
| Published | property OnUpdate: TUiUpdateEvent read FOnUpdate write FOnUpdate; |
| Published | property OnPress: TUiPressReleaseEvent read FOnPress write FOnPress; |
| Published | property OnRelease: TUiPressReleaseEvent read FOnRelease write FOnRelease; |
| Published | property OnMotion: TUiMotionEvent read FOnMotion write FOnMotion; |
| Published | property OnRender: TUiNotifyEvent read FOnRender write FOnRender; |
| Published | property Exists: boolean read FExists write SetExists default true; |
| Published | property Left: Single read FLeft write SetLeft stored false default 0; deprecated 'use Translation.X'; |
| Published | property Bottom: Single read FBottom write SetBottom default 0; deprecated 'use Translation.Y'; |
| Published | property FullSize: boolean read FFullSize write SetFullSize default false; |
| Published | property Width: Single read FWidth write SetWidth default DefaultWidth; |
| Published | property Height: Single read FHeight write SetHeight default DefaultHeight; |
| Published | property WidthFraction: Single read FWidthFraction write SetWidthFraction default 0.0; |
| Published | property HeightFraction: Single read FHeightFraction write SetHeightFraction default 0.0; |
| Published | property AutoSizeToChildren: Boolean
read FAutoSizeToChildren write SetAutoSizeToChildren default false; |
| Published | property AutoSizeToChildrenPaddingRight: Single
read FAutoSizeToChildrenPaddingRight
write SetAutoSizeToChildrenPaddingRight default 0; |
| Published | property AutoSizeToChildrenPaddingTop: Single
read FAutoSizeToChildrenPaddingTop
write SetAutoSizeToChildrenPaddingTop default 0; |
| Published | property HorizontalAnchorSelf: THorizontalPosition
read FHorizontalAnchorSelf write SetHorizontalAnchorSelf default hpLeft; |
| Published | property HorizontalAnchorParent: THorizontalPosition
read FHorizontalAnchorParent write SetHorizontalAnchorParent default hpLeft; |
| Published | property VerticalAnchorSelf: TVerticalPosition
read FVerticalAnchorSelf write SetVerticalAnchorSelf default vpBottom; |
| Published | property VerticalAnchorParent: TVerticalPosition
read FVerticalAnchorParent write SetVerticalAnchorParent default vpBottom; |
| Published | property Culling: Boolean read FCulling write SetCulling default false; |
| Published | property ClipChildren: Boolean read FClipChildren write SetClipChildren default false; |
| Published | property Border: TBorder read FBorder; |
| Published | property CustomTheme: TCastleTheme read FCustomTheme write SetCustomTheme; |
| Published | property TooltipControl: TCastleUserInterface read FTooltipControl write SetTooltipControl; |
| Published | property EditorSelectOnHover: Boolean read FEditorSelectOnHover write FEditorSelectOnHover default true; |
| Published | property BorderColorPersistent: TCastleColorPersistent read FBorderColorPersistent ; |
| Published | property TranslationPersistent: TCastleVector2Persistent read FTranslationPersistent ; |
| Public | property OwnsCustomFont: boolean
read FOwnsCustomFont write FOwnsCustomFont default false; deprecated 'use TCastleAbstractFont (inherited from TComponent) owner mechanism'; |
| Public | property SmallFont: boolean read FSmallFont write SetSmallFont default false; deprecated 'use "FontScale := 0.5" or "CustomFont := MySmalFont" instead of "SmallFont := true", this is more flexible'; |
| Public | property OutlineColor: TCastleColor read FOutlineColor write SetOutlineColor; |
| Published | property Tooltip: string read FTooltip write FTooltip; |
| Published | property CustomFont: TCastleAbstractFont
read FCustomFont write SetCustomFont; |
| Published | property FontSize: Single read FFontSize write SetFontSize default 0.0; |
| Published | property FontScale: Single read FFontScale write SetFontScale default 1.0; |
| Published | property Outline: Cardinal read FOutline write SetOutline default 0; |
| Published | property OutlineHighQuality: boolean
read FOutlineHighQuality write SetOutlineHighQuality default false; |
| Published | property OutlineColorPersistent: TCastleColorPersistent read FOutlineColorPersistent ; |
| Public | property TintPressed : TCastleColor read FTintPressed write FTintPressed; |
| Public | property TintDisabled: TCastleColor read FTintDisabled write FTintDisabled; |
| Public | property TintFocused : TCastleColor read FTintFocused write FTintFocused; |
| Public | property TintNormal : TCastleColor read FTintNormal write FTintNormal; |
| Public | property CustomTextColor: TCastleColor read FCustomTextColor write FCustomTextColor; |
| Public | property CustomColorPressed: TCastleColor read FCustomColorPressed write SetCustomColorPressed; |
| Public | property CustomColorDisabled: TCastleColor read FCustomColorDisabled write SetCustomColorDisabled; |
| Public | property CustomColorFocused: TCastleColor read FCustomColorFocused write SetCustomColorFocused; |
| Public | property CustomColorNormal: TCastleColor read FCustomColorNormal write SetCustomColorNormal; |
| Published | property MinImageWidth: Single read FMinImageWidth write FMinImageWidth default 0; |
| Published | property MinImageHeight: Single read FMinImageHeight write FMinImageHeight default 0; |
| Published | property TextAlignment: THorizontalPosition
read FTextAlignment write SetTextAlignment default DefaultTextAlignment; |
| Published | property Alignment: THorizontalPosition
read FAlignment write SetAlignment default hpMiddle; |
| Published | property VerticalAlignment: TVerticalPosition
read FVerticalAlignment write SetVerticalAlignment default vpMiddle; |
| Published | property LineSpacing: Single read FLineSpacing write SetLineSpacing
default DefaultLineSpacing; |
| Published | property Html: boolean read FHtml write SetHtml default false; |
| Published | property CustomBackground: boolean read FCustomBackground write FCustomBackground default false; |
| Published | property Image: TCastleImagePersistent read FImage; |
| Published | property ImageScale: Single read FImageScale write SetImageScale default 1.0; |
| Published | property CustomBackgroundPressed: TCastleImagePersistent read FCustomBackgroundPressed; |
| Published | property CustomBackgroundDisabled: TCastleImagePersistent read FCustomBackgroundDisabled; |
| Published | property CustomBackgroundFocused: TCastleImagePersistent read FCustomBackgroundFocused; |
| Published | property CustomBackgroundNormal: TCastleImagePersistent read FCustomBackgroundNormal; |
| Published | property CustomTextColorUse: boolean read FCustomTextColorUse write FCustomTextColorUse default false; |
| Published | property PaddingHorizontal: Single
read FPaddingHorizontal write SetPaddingHorizontal default DefaultPaddingHorizontal; |
| Published | property PaddingVertical: Single
read FPaddingVertical write SetPaddingVertical default DefaultPaddingVertical; |
| Published | property AutoSize: boolean read FAutoSize write SetAutoSize default true; |
| Published | property AutoSizeWidth: boolean read FAutoSizeWidth write SetAutoSizeWidth default true; |
| Published | property AutoSizeHeight: boolean read FAutoSizeHeight write SetAutoSizeHeight default true; |
| Published | property MinWidth: Single read FMinWidth write SetMinWidth default 0; |
| Published | property MinHeight: Single read FMinHeight write SetMinHeight default 0; |
| Published | property OnClick: TNotifyEvent read FOnClick write FOnClick; |
| Published | property Caption: String read FCaption write SetCaption; |
| Published | property CaptionTranslate: Boolean read FCaptionTranslate write FCaptionTranslate default true; |
| Published | property Toggle: boolean read FToggle write FToggle default false; |
| Published | property Pressed: boolean read FPressed write SetPressed default false; |
| Published | property ImageLayout: TCastleButtonImageLayout
read FImageLayout write SetImageLayout default ilLeft; |
| Published | property ImageMargin: Single read FImageMargin write SetImageMargin
default DefaultImageMargin; |
| Published | property Enabled: boolean read FEnabled write SetEnabled default true; |
| Published | property EnableParentDragging: boolean
read FEnableParentDragging write FEnableParentDragging default false; |
| Published | property TintPressedPersistent: TCastleColorPersistent read FTintPressedPersistent ; |
| Published | property TintDisabledPersistent: TCastleColorPersistent read FTintDisabledPersistent ; |
| Published | property TintFocusedPersistent: TCastleColorPersistent read FTintFocusedPersistent ; |
| Published | property TintNormalPersistent: TCastleColorPersistent read FTintNormalPersistent ; |
| Published | property CustomTextColorPersistent: TCastleColorPersistent read FCustomTextColorPersistent ; |
| Published | property CustomColorPressedPersistent: TCastleColorPersistent read FCustomColorPressedPersistent ; |
| Published | property CustomColorDisabledPersistent: TCastleColorPersistent read FCustomColorDisabledPersistent ; |
| Published | property CustomColorFocusedPersistent: TCastleColorPersistent read FCustomColorFocusedPersistent ; |
| Published | property CustomColorNormalPersistent: TCastleColorPersistent read FCustomColorNormalPersistent ; |
Description
Constants
| Public | DefaultWidth = 100.0; |
|
This item has no description. | |
| Public | DefaultHeight = 100.0; |
|
This item has no description. | |
| Public | DefaultImageMargin = 10; |
|
This item has no description. | |
| Public | DefaultPaddingHorizontal = 10; |
|
This item has no description. | |
| Public | DefaultPaddingVertical = 10; |
|
This item has no description. | |
| Public | DefaultLineSpacing = 2; |
|
This item has no description. | |
| Public | DefaultTextAlignment = hpMiddle; |
|
This item has no description. | |
Methods
| Protected | function GetInternalText: String; virtual; |
|
This item has no description. | |
| Protected | procedure SetInternalText(const Value: String); virtual; |
|
This item has no description. | |
| Protected | procedure SetName(const Value: TComponentName); override; |
|
This item has no description. | |
| Protected | procedure TranslateProperties(const TranslatePropertyEvent: TTranslatePropertyEvent); virtual; |
|
Enumerate all properties that are possible to translate in this component. E.g. in TCastleLabel it will return TCastleLabel.Caption, in TCastleEdit it will return TCastleEdit.Text and TCastleEdit.Placeholder. Returns only non-empty properties, thus assuming that if current (by convention, English) text is empty, then there is no point in translating it. Moreover descendants may define boolean properties to exclude particular text from translating, e.g. TCastleLabel.CaptionTranslate, TCastleEdit.TextTranslate, TCastleEdit.PlaceholderTranslate. It is not recursive (it doesn't enumerate children properties). Use global TranslateProperties procedure to call this on a hierarchy of TComponent. You usually don't want to call this method (it is called by other engine routines). But you may find it useful to override this, if you define new component. | |
| Public | destructor Destroy; override; |
|
This item has no description. | |
| Public | procedure CustomSerialization(const SerializationProcess: TSerializationProcess); virtual; |
|
Override this method to call various methods of SerializationProcess, which in turn allows to serialize/deserialize things that are not published. This allows to serialize/deserialize with more freedom, e.g. to serialize/deserialize some private field. | |
| Public | function PropertySections(const PropertyName: String): TPropertySections; virtual; |
|
Section where to show property in the editor. | |
| Public | procedure SetTransient; |
|
Ignore this component when serializing parent's TCastleUserInterface.Controls list or TCastleTransform.List, and do not show this component in CGE editor. This simply sets csTransient flag in ComponentStyle. This is useful for children that are automatically managed by the parent, and should not be modified by user code. For example, TCastleCheckbox is internally composed from TCastleImageControl and TCastleLabel children, but we don't want to serialize or even show these children to user. Note that if you want to prevent this component from serializing as part of TCastleUserInterface.Controls list or TCastleTransform.List, but you still want it to be visible in CGE editor, then make it a "subcomponent" instead, by Note that both csSubComponent and csTransient only disable the component serialization as part of parent's lists enumerated by CustomSerialization (see internal TCastleUserInterface.SerializeChildrenEnumerate , TCastleTransform.SerializeChildrenEnumerate, TCastleTransform.SerializeBehaviorsEnumerate). If you will make the component published in its own property (which is normal for "subcomponents") then it will be serialized anyway, just as part of it's own property (like TCastleScrollView.ScrollArea). So to really avoid serializing a children component make it csSubComponent and/or csTransient, and do not publish it. | |
| Public | procedure AddNonVisualComponent(const NonVisualComponent: TComponent); |
|
Add non-visual component to this component. This is used to organize non-visual components in a tree hierarchy, in CGE designs and editor.
See also
| |
| Public | procedure InsertNonVisualComponent(const Index: Integer; const NonVisualComponent: TComponent); |
|
Insert non-visual component to this component. This is used to organize non-visual components in a tree hierarchy, in CGE designs and editor.
See also
| |
| Public | procedure RemoveNonVisualComponent(const NonVisualComponent: TComponent); |
|
Removes the component previously added by AddNonVisualComponent. | |
| Public | function NonVisualComponentsIndexOf(const NonVisualComponent: TComponent): Integer; |
|
Index of the previously added non-visual component. Returns -1 if the component was not found. | |
| Public | function NonVisualComponentsCount: Integer; |
|
Count of components added by AddNonVisualComponent.
See also
| |
| Public | function NonVisualComponentsEnumerate: TNonVisualComponentsEnumerator; |
|
You can enumerate current non-visual components using loop like See also
| |
| Public | function ValueIsStreamed: Boolean; virtual; |
|
Whether the current value of this object should be written to the stream. This should be This is used by CastleComponentSerialize, which is used in Castle Game Engine for all serialization. In simple cases, this just says whether the current value of this object equals to some default value. The default implementation of this class returns Descendants that override this to sometimes return The name of this method is consistent with TPropertyEditor.ValueIsStreamed in LCL. | |
| Public | procedure DesignerInfo(const SList: TStrings); virtual; |
|
Override to add information that should be visible at design-time. Call | |
| Public | procedure DesignerWarnings(const SList: TStrings); virtual; |
|
Override to add warnings that should be visible at design-time. Call | |
| Protected | procedure Loaded; override; |
|
This item has no description. | |
| Protected | function ContainerWidth: Cardinal; virtual; deprecated 'arrange UI using anchors, FullSize and friends; if you really need container size, use "Container.UnscaledWidth" or "Container.PixelsWidth" after checking "Container <> nil"'; |
|
Warning: this symbol is deprecated: arrange UI using anchors, FullSize and friends; if you really need container size, use "Container.UnscaledWidth" or "Container.PixelsWidth" after checking "Container <> nil" Container sizes. | |
| Protected | function ContainerHeight: Cardinal; virtual; deprecated 'arrange UI using anchors, FullSize and friends; if you really need container size, use "Container.UnscaledHeight" or "Container.PixelsHeight" after checking "Container <> nil"'; |
|
Warning: this symbol is deprecated: arrange UI using anchors, FullSize and friends; if you really need container size, use "Container.UnscaledHeight" or "Container.PixelsHeight" after checking "Container <> nil" This item has no description. | |
| Protected | function ContainerRect: TRectangle; virtual; deprecated 'arrange UI using anchors, FullSize and friends; if you really need container size, use "Container.UnscaledRect" or "Container.PixelsRect" after checking "Container <> nil"'; |
|
Warning: this symbol is deprecated: arrange UI using anchors, FullSize and friends; if you really need container size, use "Container.UnscaledRect" or "Container.PixelsRect" after checking "Container <> nil" This item has no description. | |
| Protected | function ContainerSizeKnown: boolean; virtual; deprecated 'arrange UI using anchors, FullSize and friends; if you really need container size, use "Container.UnscaledWidth/Height" or "Container.PixelsWidth/Height" after checking "Container <> nil"'; |
|
Warning: this symbol is deprecated: arrange UI using anchors, FullSize and friends; if you really need container size, use "Container.UnscaledWidth/Height" or "Container.PixelsWidth/Height" after checking "Container <> nil" This item has no description. | |
| Protected | procedure DoCursorChange; virtual; deprecated 'better override VisibleChange and watch for chCursor in Changes'; |
|
Warning: this symbol is deprecated: better override VisibleChange and watch for chCursor in Changes Called when Cursor changed. In TCastleUserInterface class, just calls OnCursorChange. | |
| Protected | procedure DefineProperties(Filer: TFiler); override; |
|
This item has no description. | |
| Protected | procedure UIScaleChanged; virtual; |
|
This item has no description. | |
| Protected | procedure PreferredSize(var PreferredWidth, PreferredHeight: Single); virtual; |
|
Controls that have a preferred size should override this. By default this contains values derived from Width, WidthFraction, Height, HeightFraction, with Border subtracted. Note that the arguments should be already scaled, i.e. multiplied by UIScale, i.e. expressed in final device pixels. Note that the returned PreferredWidth and PreferredHeight must not include the space for Border. Border size will be added later. | |
| Protected | procedure BeforeSizing; virtual; |
|
Called right before calculating size. This is your only chance to adjust e.g. children size, if you need them to be synchronized with something, and you may use AutoSizeToChildren. In most use-cases, you rather adjust preferred size by overriding PreferredSize. | |
| Protected | procedure DoInternalMouseEnter; virtual; |
|
This item has no description. | |
| Protected | procedure DoInternalMouseLeave; virtual; |
|
This item has no description. | |
| Protected | function Theme: TCastleTheme; |
|
Theme that should be used by this control. Either CustomTheme or global Theme. | |
| Public | constructor Create(AOwner: TComponent); override; |
|
This item has no description. | |
| Public | destructor Destroy; override; |
|
This item has no description. | |
| Public | procedure CustomSerialization(const SerializationProcess: TSerializationProcess); override; |
|
This item has no description. Showing description inherited from TCastleComponent.CustomSerialization. Override this method to call various methods of SerializationProcess, which in turn allows to serialize/deserialize things that are not published. This allows to serialize/deserialize with more freedom, e.g. to serialize/deserialize some private field. | |
| Public | function PropertySections(const PropertyName: String): TPropertySections; override; |
|
This item has no description. Showing description inherited from TCastleComponent.PropertySections. Section where to show property in the editor. | |
| Public | procedure DesignerInfo(const SList: TStrings); override; |
|
This item has no description. Showing description inherited from TCastleComponent.DesignerInfo.
Override to add information that should be visible at design-time. Call | |
| Public | procedure DesignerWarnings(const SList: TStrings); override; |
|
This item has no description. Showing description inherited from TCastleComponent.DesignerWarnings.
Override to add warnings that should be visible at design-time. Call | |
| Public | function GetEnumerator: TEnumerator; |
|
This item has no description. | |
| Public | procedure InternalSetContainer(const Value: TCastleContainer); virtual; |
|
This item has no description. | |
| Public | function Press(const Event: TInputPressRelease): boolean; virtual; |
|
Override this method to react to user pressing a key, mouse button or mouse wheel. Return When implementing in descendants it is best to override it like this: function TMyControl.Press(const Event: TInputPressRelease): boolean; begin Result := inherited; if Result then Exit; // exit if ancestor already handled this event if Event.IsKey(keyEnter) then begin // do something in reaction to Enter key ... // let engine know that this input event was handled Exit(true); end; if Event.IsMouseButton(buttonLeft) then begin // do something in reaction to left mouse button press ... // let engine know that this input event was handled Exit(true); end; end;
These events are generated for all UI controls, whether they are considered "interactive" or not. These events are generated for non-interactive controls like TCastleRectangleControl or TCastleLabel as well. For example, these events ignore the TCastleButton.Enabled state, they are generated always (see https://github.com/castle-engine/castle-engine/issues/413 ). Use instead TCastleButton.OnClick to detect clicks on a button in a way that honors the TCastleButton.Enabled state. When a control returns The events Press and Release are passed to the parent only after the children had a chance to process this event. Overriding them makes sense if you draw something that "looks clickable" in TCastleUserInterface.Render, which is the standard place you should draw stuff. For example our TCastleButton draws there. In contrast, the events PreviewPress and PreviewRelease are passed first to the parent control, before children have a chance to process this event. In partcular, overriding them makes sense if you draw something that "looks clickable" in TCastleUserInterface.RenderOverChildren. | |
| Public | function Release(const Event: TInputPressRelease): boolean; virtual; |
|
Override this method to react to user releasing a key, mouse button. Return This is counterpart to Press method. See Press for more details. Note: We'd like this method to also be called when user releases a mouse wheel. But currently releasing of the mouse wheel is not reported now by any backend. Only releasing of keys and mouse buttons is reported. See also
| |
| Public | function PreviewPress(const Event: TInputPressRelease): boolean; virtual; |
|
Similar to Press but allows the parent control to preview the event before it is passed to children UI controls. See also
| |
| Public | function PreviewRelease(const Event: TInputPressRelease): boolean; virtual; |
|
Similar to Release but allows the parent control to preview the event before it is passed to children UI controls. See also
| |
| Public | function Motion(const Event: TInputMotion): boolean; virtual; |
|
Motion of mouse or touch. | |
| Public | function SensorRotation(const X, Y, Z, Angle: Double; const SecondsPassed: Single): boolean; virtual; |
|
Rotation detected by 3D sensor. Used for example by 3Dconnexion devices.
Parameters
| |
| Public | function SensorTranslation(const X, Y, Z, Length: Double; const SecondsPassed: Single): boolean; virtual; |
|
Translation detected by 3D sensor. Used for example by 3Dconnexion devices.
Parameters
| |
| Public | procedure Update(const SecondsPassed: Single; var HandleInput: boolean); virtual; |
|
Control may do here anything that must be continuously repeated. E.g. camera handles here falling down due to gravity, rotating model in Examine mode, and many more.
This method may be used, among many other things, to continuously react to the fact that user pressed some key (or mouse button). For example, if holding some key should move some 3D object, you should do something like: if HandleInput then begin if Container.Pressed[keyArrowRight] then begin Transform.Position := Transform.Position + Vector3(SecondsPassed * 10, 0, 0); HandleInput := false; end; end;
Instead of directly using a key code, consider also using TInputShortcut that makes the input key nicely configurable. See engine tutorial about handling inputs. Multiplying movement by SecondsPassed makes your operation frame-rate independent. Object will move by 10 units in a second, regardless of how many FPS your game has. The code related to HandleInput is important if you write a generally-useful control that should nicely cooperate with all other controls, even when placed on top of them or under them. The correct approach is to only look at pressed keys/mouse buttons if HandleInput is Note that to handle a single press / release (like "switch light on when pressing a key") you should rather use Press and Release methods. Use this method only for continuous handling (like "holding this key makes the light brighter and brighter"). To understand why such HandleInput approach is needed, realize that the "Update" events are called differently than simple mouse and key events like "Press" and "Release". "Press" and "Release" events return whether the event was somehow "handled", and the container passes them only to the controls under the mouse (decided by TCastleUserInterface.CapturesEventsAtPosition). And as soon as some control says it "handled" the event, other controls (even if under the mouse) will not receive the event. This approach is not suitable for Update events. Some controls need to do the Update job all the time, regardless of whether the control is under the mouse and regardless of what other controls already did. So all controls (well, all controls that exist, in case of TCastleUserInterface, see TCastleUserInterface.Exists) receive Update calls. So the "handled" status is passed through HandleInput. If a control is not under the mouse, it will receive HandleInput = Parameters
| |
| Public | procedure VisibleChange(const Changes: TCastleUserInterfaceChanges; const ChangeInitiatedByChildren: boolean = false); overload; virtual; |
|
Called always when something important inside this control (or it's children) changed. To be more precise, this is called when something mentioned among the TCastleUserInterfaceChange enumerated items changed. This is always called with Changes <> [] (non-empty set). | |
| Public | function AllowSuspendForInput: boolean; virtual; |
|
Allow window containing this control to suspend waiting for user input. Typically you want to override this to return In this class, this simply returns always See also
| |
| Public | procedure Resize; virtual; |
|
Event called when the container (component or window with OpenGL context) size changes. You can resize/reposition your component here to react to parent size changes. This is called only when the rendering context of the container is initialized, so you can be sure that this is called only between GLContextOpen and GLContextClose. We also call this once when inserting into the controls list (like TCastleWindow.Controls or TCastleControl.Controls or inside parent TCastleUserInterface), if inserting into the container/parent with already initialized OpenGL context. If inserting into the container/parent without OpenGL context initialized, it will be called later, when OpenGL context will get initialized, right after GLContextOpen. In other words, this is always called to let the control know the size of the container, if and only if the OpenGL context is initialized. | |
| Public | function ControlsCount: Integer; |
|
This item has no description. | |
| Public | procedure InsertFront(const NewItem: TCastleUserInterface); overload; |
|
Add child control, at the front of other children. | |
| Public | procedure InsertFrontIfNotExists(const NewItem: TCastleUserInterface); |
|
This item has no description. | |
| Public | procedure InsertFront(const NewItems: TCastleUserInterfaceList); overload; |
|
This item has no description. | |
| Public | procedure InsertBack(const NewItem: TCastleUserInterface); overload; |
|
Add child control, at the back of other children. | |
| Public | procedure InsertBackIfNotExists(const NewItem: TCastleUserInterface); |
|
This item has no description. | |
| Public | procedure InsertBack(const NewItems: TCastleUserInterfaceList); overload; |
|
This item has no description. | |
| Public | procedure InsertControl(const Index: Integer; const NewItem: TCastleUserInterface); |
|
Add child control at specified position. It is usually easier to use InsertFront or InsertBack, if possible. | |
| Public | procedure RemoveControl(const Item: TCastleUserInterface); |
|
Remove control added by InsertFront or InsertBack. Note that this method does not free the Item instance. This method merely removes Item from our controls, so that Item is no longer rendered as part of this parent. It is still the caller's responsibility to make sure the Item is freed at some point. See https://castle-engine.io/modern_pascal#_freeing_classes for description how to free instances in Pascal. As TCastleUserInterface descends from TComponent, a simple and proper solution is often just to create it with some "owner" (like TCastleView.FreeAtStop or Application) that will take care of freeing it. | |
| Public | function IndexOfControl(const Item: TCastleUserInterface): Integer; |
|
Index of child control, or -1 if not present. | |
| Public | procedure ClearControls; |
|
Remove all child controls added by InsertFront or InsertBack. Note that, just like RemoveControl, this method does not free the children controls. This method merely removes children controls, so they are no longer rendered as part of the parent. It is still the caller's responsibility to make sure the children controls are freed at some point. See https://castle-engine.io/modern_pascal#_freeing_classes for description how to free instances in Pascal. As TCastleUserInterface descends from TComponent, a simple and proper solution is often just to create it with some "owner" (like TCastleView.FreeAtStop or Application) that will take care of freeing it. | |
| Public | procedure MoveToFront; |
|
Move to become the front-most control within the parent. This works when this control is a child of another control (has Parent assigned) or when it's a direct child of the container (in which case Parent is not assigned by Container is, which means the control is directly on TCastleContainer.Controls list). This is ignored if this control is not within any container (so, also not within any parent). | |
| Public | function CapturesEventsAtPosition(const Position: TVector2): boolean; virtual; |
|
Does this control capture events under this container position. The default implementation simply checks whether Position is inside RenderRect. It also checks whether CapturesEvents is Always treated like | |
| Public | procedure BeforeRender; virtual; |
|
Prepare your resources, right before drawing. Called only when Exists and GLInitialized. Do not explicitly call this method. Instead, render controls by adding them to the TCastleContainer.Controls list, or render them explicitly (for off-screen rendering) by TCastleContainer.RenderControl. | |
| Public | procedure Render; virtual; |
|
Render a control. Called only when Exists and render context is initialized. Do not call this method. It will be automatically called by the engine when needed. It will be called when UI is part of TCastleContainer.Controls list or rendered (e.g. for off-screen rendering) by TCastleContainer.RenderControl. You should only override this method. See https://castle-engine.io/manual_2d_ui_custom_drawn.php for examples what you can put here. You can depend on some OpenGL state being set before calling this method. You can depend on it being set, and you can carelessly change it. This state we set:
Beware that GLSL RenderContext.CurrentProgram has undefined value when this is called. You should always set it, before making direct OpenGL drawing calls (all the engine drawing routines do it already, this is only a concern if you make direct OpenGL / OpenGLES calls). | |
| Public | procedure RenderOverChildren; virtual; |
|
Render a control contents over the children controls. This is analogous to Render, but it executes after children are drawn. You should usually prefer to override Render instead of this method, as the convention is that the parent is underneath children. You should only override this method (do not call it, it will be called by the engine). See https://castle-engine.io/manual_2d_ui_custom_drawn.php for examples what you can put here. | |
| Public | function TooltipExists: Boolean; virtual; deprecated 'use TooltipControl to customize tooltip look'; |
|
Warning: this symbol is deprecated: use TooltipControl to customize tooltip look
Render a tooltip of this control. If you want to have tooltip for this control detected, you have to override TooltipRender is called in the same way as Render. TooltipRender is always called as a last (front-most) control. Argument TooltipPosition is the left-bottom (in screen space, regardless of UIScaling) suggested position of the tooltip. It is simplest to descend from TCastleUserInterfaceFont, that implements simple TCastleUserInterfaceFont.Tooltip property and overrides these two methods as necessary. | |
| Public | procedure TooltipRender(const TooltipPosition: TVector2); virtual; deprecated 'use TooltipControl to customize tooltip look'; |
|
Warning: this symbol is deprecated: use TooltipControl to customize tooltip look This item has no description. | |
| Public | procedure GLContextOpen; virtual; |
|
Initialize your OpenGL resources. This is called when OpenGL context of the container is created, or when the control is added to the already existing context. In other words, this is the moment when you can initialize OpenGL resources, like display lists, VBOs, OpenGL texture names, etc. As an exception, this is called regardless of the Exists value. This way a control can prepare it's resources, regardless if it exists now. | |
| Public | procedure GLContextClose; virtual; |
|
Destroy your OpenGL resources. Called when OpenGL context of the container is destroyed. Also called when controls is removed from the container You should release here any resources that are tied to the OpenGL context. In particular, the ones created in GLContextOpen. As an exception, this is called regardless of the Exists value. This way a control can release it's resources, regardless if it exists now. | |
| Public | procedure SetFocused(const Value: boolean); virtual; |
|
Called when this control becomes or stops being focused, that is: under the mouse cursor and will receive events. This updates Focused property. This also calls OnInternalMouseEnter / OnInternalMouseLeave. | |
| Public | function EffectiveRect: TFloatRectangle; |
|
Control position and size. Use this to base other controls size/position on this control's calculated size/position. The algorithm that determines control position and size is like this:
The above describes the size of the content and border, summed. The content itself may be a little smaller, when the Border is used. The size of the "content itself" is returned only by The anchors (see Anchor) also affect the final position of the control. Note that some descendants do auto-sizing by default. This means that some of these properties may be ignored, and instead the calculated size (EffectiveWidth, EffectiveHeight) depends on some core values of the control. For example:
Consult the documentation of each descendant for the exact specification of the size behavior. This method returns the rectangle in local coordinates (relative to the parent 2D control). The returned rectangle size includes the border size. The returned rectangle size uses "unscaled" coordinates, which means that they correspond to the sizes you set e.g. in TCastleUserInterface.Width, TCastleUserInterface.Height, and translation units you use with e.g. TCastleUserInterface.Anchor. If you're looking for a way to query the size of the control in final scaled coordinates (in real device pixels), and not relative to the parent position, use RenderRect or RenderRectWithBorder instead. This method ignores the current value of the Exists method and Exists property, that is: the result of this function assumes that control does exist.
See also
| |
| Public | function EffectiveWidth: Single; |
|
Calculated width of the control, without UI scaling. Useful if you want to base other controls size/position on this control calculated size. Unlike the Width property, this is the effective size, not the desired size. So this is already processed by any auto-sizing mechanism (e.g. TCastleImageControl may adjust it's own size to the underlying image, depending on settings), it is changed by FullSize and so on. It is always equal to just See also
| |
| Public | function EffectiveHeight: Single; |
|
Calculated height of the control, without UI scaling. Useful if you want to base other controls size/position on this control calculated size. Unlike the Height property, this is the effective size, not the desired size. So this is already processed by any auto-sizing mechanism (e.g. TCastleImageControl may adjust it's own size to the underlying image, depending on settings), it is changed by FullSize and so on. It is always equal to just See also
| |
| Public | function EffectiveWidthForChildren: Single; |
|
EffectiveWidth without Border size. | |
| Public | function EffectiveHeightForChildren: Single; |
|
EffectiveHeight without Border size. | |
| Public | function CalculatedWidth: Cardinal; deprecated 'use EffectiveWidth'; |
|
Warning: this symbol is deprecated: use EffectiveWidth This item has no description. | |
| Public | function CalculatedHeight: Cardinal; deprecated 'use EffectiveHeight'; |
|
Warning: this symbol is deprecated: use EffectiveHeight This item has no description. | |
| Public | function CalculatedRect: TRectangle; deprecated 'use EffectiveRect'; |
|
Warning: this symbol is deprecated: use EffectiveRect This item has no description. | |
| Public | function RenderRect: TFloatRectangle; |
|
Position and size of this control, assuming it exists, in container coordinates (in final device pixels). The primary use of this is inside Render. A proper UI control should adjust to draw precisely in this rectangle. | |
| Public | function RenderRectWithBorder: TFloatRectangle; |
|
This item has no description. | |
| Public | function ScreenRect: TRectangle; deprecated 'use RenderRect'; |
|
Warning: this symbol is deprecated: use RenderRect This item has no description. | |
| Public | function ContainerToLocalPosition(ContainerPosition: TVector2; const ContainerPositionScaled: Boolean = true): TVector2; |
|
Convert position relative to container (in final device coordinates, without UI scaling, by default) into position relative to this UI control (in coordinates with UI scaling). Useful e.g. to convert mouse/touch position from TInputPressRelease.Position into position useful for children of this UI control. The exact definition is that using the result of this to set our child Translation, assuming the child is anchored to the left-bottom (the default state) and child has Left = Bottom = 0, sets child position exactly to the indicated point on the container. Parameters
| |
| Public | function LocalToContainerPosition(const LocalPosition: TVector2; const ContainerPositionScaled: Boolean = true): TVector2; |
|
Convert position relative to this UI control (in coordinates with UI scaling) into relative to container (in final device coordinates, without UI scaling, by default). Reverses ContainerToLocalPosition. Parameters
| |
| Public | function ParentRect: TFloatRectangle; |
|
Rectangle filling the parent control (or container), in local coordinates. Since this is in local coordinates, the returned rectangle Left and Bottom are always zero, unless parent has Border (the returned rectangle is shrunk by Parent.Border). This is already scaled by UI scaling. | |
| Public | procedure Anchor(const AHorizontalAnchor: THorizontalPosition; const TranslationX: Single = 0); overload; |
|
Adjust position to align us with the parent horizontally. The resulting EffectiveRect and RenderRect and RenderRectWithBorder will immediately reflect the new position. Note that position set here (anchors, Translation) are ignored when FullSize is set to true. In case of FullSize, the control fills the parent perfectly. This utility method sets HorizontalAnchorSelf, HorizontalAnchorParent, Translation.X. | |
| Public | procedure Anchor( const AHorizontalAnchorSelf, AHorizontalAnchorParent: THorizontalPosition; const TranslationX: Single = 0); overload; |
|
Adjust position to align us with the parent horizontally. The resulting EffectiveRect and RenderRect and RenderRectWithBorder will immediately reflect the new position. Note that position set here (anchors, Translation) are ignored when FullSize is set to true. In case of FullSize, the control fills the parent perfectly. This utility method sets HorizontalAnchorSelf, HorizontalAnchorParent, Translation.X. | |
| Public | procedure Anchor(const AVerticalAnchor: TVerticalPosition; const TranslationY: Single = 0); overload; |
|
Adjust position to align us to the parent vertically. The resulting EffectiveRect and RenderRect and RenderRectWithBorder will immediately reflect the new position. Note that position set here (anchors, Translation) are ignored when FullSize is set to true. In case of FullSize, the control fills the parent perfectly. This utility method sets VerticalAnchorSelf, VerticalAnchorParent, Translation.Y. | |
| Public | procedure Anchor( const AVerticalAnchorSelf, AVerticalAnchorParent: TVerticalPosition; const TranslationY: Single = 0); overload; |
|
Adjust position to align us to the parent vertically. The resulting EffectiveRect and RenderRect and RenderRectWithBorder will immediately reflect the new position. Note that position set here (anchors, Translation) are ignored when FullSize is set to true. In case of FullSize, the control fills the parent perfectly. This utility method sets VerticalAnchorSelf, VerticalAnchorParent, Translation.Y. | |
| Public | procedure AlignHorizontal( const ControlPosition: TPositionRelative = prMiddle; const ContainerPosition: TPositionRelative = prMiddle; const X: Single = 0); deprecated 'use Anchor'; |
|
Warning: this symbol is deprecated: use Anchor Immediately position the control with respect to the parent by adjusting Left. Deprecated, use Align with THorizontalPosition. | |
| Public | procedure Align( const ControlPosition: THorizontalPosition; const ContainerPosition: THorizontalPosition; const X: Single = 0); overload; deprecated 'use Anchor'; |
|
Warning: this symbol is deprecated: use Anchor Immediately position the control with respect to the parent by adjusting Left. Note that using Anchor is often more comfortable than this method, since you only need to set anchor once (for example, right after creating the control). In contrast, adjusting position using this method will typically need to be repeated at each window on resize, like in TCastleUserInterface.Resize. | |
| Public | procedure AlignVertical( const ControlPosition: TPositionRelative = prMiddle; const ContainerPosition: TPositionRelative = prMiddle; const Y: Single = 0); deprecated 'use Anchor'; |
|
Warning: this symbol is deprecated: use Anchor Immediately position the control with respect to the parent by adjusting Bottom. Deprecated, use Align with TVerticalPosition. | |
| Public | procedure Align( const ControlPosition: TVerticalPosition; const ContainerPosition: TVerticalPosition; const Y: Single = 0); overload; deprecated 'use Anchor'; |
|
Warning: this symbol is deprecated: use Anchor Immediately position the control with respect to the parent by adjusting Bottom. Note that using Anchor is often more comfortable than this method, since you only need to set anchor once (for example, right after creating the control). In contrast, adjusting position using this method will typically need to be repeated at each window on resize, like in TCastleUserInterface.Resize. | |
| Public | procedure Center; deprecated 'use Anchor(hpMiddle); Anchor(vpMiddle); to reliably center the control'; |
|
Warning: this symbol is deprecated: use Anchor(hpMiddle); Anchor(vpMiddle); to reliably center the control Immediately center the control within the parent, both horizontally and vertically. Note that using Anchor is often more comfortable than this method, since you only need to set anchor once. For example, right after creating the control call | |
| Public | function UIScale: Single; virtual; |
|
UI scale of this control, derived from container (see TCastleContainer.UIScaling and EnableUIScaling). | |
| Public | procedure EditorAllowResize(out ResizeWidth, ResizeHeight: Boolean; out Reason: String); virtual; |
|
Override this to prevent resizing some dimension in CGE editor. | |
| Public | function EffectiveFullSize: Boolean; |
|
Is the FullSize actually active. Checks FullSize and not AutoSizeToChildren, i.e. it accounts that AutoSizeToChildren overrides FullSize (since they cannot both work at the same time). | |
| Protected | procedure InternalSetTooltipExists(const Value: Boolean); override; |
|
This item has no description. | |
| Protected | procedure UIScaleChanged; override; |
|
This item has no description. | |
| Protected | procedure Notification(AComponent: TComponent; Operation: TOperation); override; |
|
This item has no description. | |
| Public | constructor Create(AOwner: TComponent); override; |
|
This item has no description. | |
| Public | destructor Destroy; override; |
|
This item has no description. | |
| Public | function TooltipExists: boolean; override; |
|
This item has no description. Showing description inherited from TCastleUserInterface.TooltipExists.
Render a tooltip of this control. If you want to have tooltip for this control detected, you have to override TooltipRender is called in the same way as Render. TooltipRender is always called as a last (front-most) control. Argument TooltipPosition is the left-bottom (in screen space, regardless of UIScaling) suggested position of the tooltip. It is simplest to descend from TCastleUserInterfaceFont, that implements simple TCastleUserInterfaceFont.Tooltip property and overrides these two methods as necessary. | |
| Public | procedure TooltipRender(const TooltipPosition: TVector2); override; |
|
This item has no description. | |
| Public | procedure Render; override; |
|
This item has no description. Showing description inherited from TCastleUserInterface.Render. Render a control. Called only when Exists and render context is initialized. Do not call this method. It will be automatically called by the engine when needed. It will be called when UI is part of TCastleContainer.Controls list or rendered (e.g. for off-screen rendering) by TCastleContainer.RenderControl. You should only override this method. See https://castle-engine.io/manual_2d_ui_custom_drawn.php for examples what you can put here. You can depend on some OpenGL state being set before calling this method. You can depend on it being set, and you can carelessly change it. This state we set:
Beware that GLSL RenderContext.CurrentProgram has undefined value when this is called. You should always set it, before making direct OpenGL drawing calls (all the engine drawing routines do it already, this is only a concern if you make direct OpenGL / OpenGLES calls). | |
| Public | function PropertySections(const PropertyName: String): TPropertySections; override; |
|
This item has no description. Showing description inherited from TCastleComponent.PropertySections. Section where to show property in the editor. | |
| Public | procedure AssignFont(const Source: TCastleUserInterfaceFont); |
|
Copy font properties from another control. | |
| Public | function Font: TCastleAbstractFont; |
|
Font used for rendering and measuring this control. Depending on which one is set, this method returns CustomFont or TCastleContainer.DefaultFont or global UIFont. It may also return a TCastleFontFamily instance that wraps (and scales) one of them. | |
| Public | procedure CheckFontChanged; |
|
Check does currently used font (see Font) changed, and eventually call FontChanged method now. You only need to explicitly call this in very specific circumstances, when you just changed UIFont or TCastleContainer.DefaultFont and you want control size to be updated immediately (for example, you need EffectiveHeight to be immediately valid). Without calling this, it could be updated only at next Render call. Changing CustomFont automatically calls this. | |
| Public | procedure FontChanged; virtual; |
|
Force considering font changed (font instance, or glyphs, or sizes changed). Usually, you don't need to call this explicitly from the outside. Changing font, like CustomFont or TCastleContainer.DefaultFont or UIFont, or any property that may affect the font is automatically applied. But there are exceptions: right now, if you call Load on a font, it's measurements will change but some controls using it will not recalculate sizes automatically. In this case, call this method. | |
| Protected | procedure SetPressed(const Value: boolean); virtual; |
|
This item has no description. | |
| Protected | procedure UIScaleChanged; override; |
|
This item has no description. | |
| Protected | procedure PreferredSize(var PreferredWidth, PreferredHeight: Single); override; |
|
This item has no description. Showing description inherited from TCastleUserInterface.PreferredSize. Controls that have a preferred size should override this. By default this contains values derived from Width, WidthFraction, Height, HeightFraction, with Border subtracted. Note that the arguments should be already scaled, i.e. multiplied by UIScale, i.e. expressed in final device pixels. Note that the returned PreferredWidth and PreferredHeight must not include the space for Border. Border size will be added later. | |
| Protected | function GetInternalText: String; override; |
|
This item has no description. | |
| Protected | procedure SetInternalText(const Value: String); override; |
|
This item has no description. | |
| Protected | procedure TranslateProperties(const TranslatePropertyEvent: TTranslatePropertyEvent); override; |
|
This item has no description. Showing description inherited from TCastleComponent.TranslateProperties. Enumerate all properties that are possible to translate in this component. E.g. in TCastleLabel it will return TCastleLabel.Caption, in TCastleEdit it will return TCastleEdit.Text and TCastleEdit.Placeholder. Returns only non-empty properties, thus assuming that if current (by convention, English) text is empty, then there is no point in translating it. Moreover descendants may define boolean properties to exclude particular text from translating, e.g. TCastleLabel.CaptionTranslate, TCastleEdit.TextTranslate, TCastleEdit.PlaceholderTranslate. It is not recursive (it doesn't enumerate children properties). Use global TranslateProperties procedure to call this on a hierarchy of TComponent. You usually don't want to call this method (it is called by other engine routines). But you may find it useful to override this, if you define new component. | |
| Public | constructor Create(AOwner: TComponent); override; |
|
This item has no description. | |
| Public | destructor Destroy; override; |
|
This item has no description. | |
| Public | procedure Render; override; |
|
This item has no description. Showing description inherited from TCastleUserInterface.Render. Render a control. Called only when Exists and render context is initialized. Do not call this method. It will be automatically called by the engine when needed. It will be called when UI is part of TCastleContainer.Controls list or rendered (e.g. for off-screen rendering) by TCastleContainer.RenderControl. You should only override this method. See https://castle-engine.io/manual_2d_ui_custom_drawn.php for examples what you can put here. You can depend on some OpenGL state being set before calling this method. You can depend on it being set, and you can carelessly change it. This state we set:
Beware that GLSL RenderContext.CurrentProgram has undefined value when this is called. You should always set it, before making direct OpenGL drawing calls (all the engine drawing routines do it already, this is only a concern if you make direct OpenGL / OpenGLES calls). | |
| Public | function Press(const Event: TInputPressRelease): boolean; override; |
|
This item has no description. Showing description inherited from TCastleUserInterface.Press.
Override this method to react to user pressing a key, mouse button or mouse wheel. Return When implementing in descendants it is best to override it like this: function TMyControl.Press(const Event: TInputPressRelease): boolean; begin Result := inherited; if Result then Exit; // exit if ancestor already handled this event if Event.IsKey(keyEnter) then begin // do something in reaction to Enter key ... // let engine know that this input event was handled Exit(true); end; if Event.IsMouseButton(buttonLeft) then begin // do something in reaction to left mouse button press ... // let engine know that this input event was handled Exit(true); end; end;
These events are generated for all UI controls, whether they are considered "interactive" or not. These events are generated for non-interactive controls like TCastleRectangleControl or TCastleLabel as well. For example, these events ignore the TCastleButton.Enabled state, they are generated always (see https://github.com/castle-engine/castle-engine/issues/413 ). Use instead TCastleButton.OnClick to detect clicks on a button in a way that honors the TCastleButton.Enabled state. When a control returns The events Press and Release are passed to the parent only after the children had a chance to process this event. Overriding them makes sense if you draw something that "looks clickable" in TCastleUserInterface.Render, which is the standard place you should draw stuff. For example our TCastleButton draws there. In contrast, the events PreviewPress and PreviewRelease are passed first to the parent control, before children have a chance to process this event. In partcular, overriding them makes sense if you draw something that "looks clickable" in TCastleUserInterface.RenderOverChildren. | |
| Public | function Release(const Event: TInputPressRelease): boolean; override; |
|
This item has no description. Showing description inherited from TCastleUserInterface.Release.
Override this method to react to user releasing a key, mouse button. Return This is counterpart to Press method. See Press for more details. Note: We'd like this method to also be called when user releases a mouse wheel. But currently releasing of the mouse wheel is not reported now by any backend. Only releasing of keys and mouse buttons is reported. | |
| Public | function Motion(const Event: TInputMotion): boolean; override; |
|
This item has no description. Showing description inherited from TCastleUserInterface.Motion. Motion of mouse or touch. | |
| Public | procedure FontChanged; override; |
|
This item has no description. Showing description inherited from TCastleUserInterfaceFont.FontChanged. Force considering font changed (font instance, or glyphs, or sizes changed). Usually, you don't need to call this explicitly from the outside. Changing font, like CustomFont or TCastleContainer.DefaultFont or UIFont, or any property that may affect the font is automatically applied. But there are exceptions: right now, if you call Load on a font, it's measurements will change but some controls using it will not recalculate sizes automatically. In this case, call this method. | |
| Public | procedure Update(const SecondsPassed: Single; var HandleInput: boolean); override; |
|
This item has no description. Showing description inherited from TCastleUserInterface.Update. Control may do here anything that must be continuously repeated. E.g. camera handles here falling down due to gravity, rotating model in Examine mode, and many more.
This method may be used, among many other things, to continuously react to the fact that user pressed some key (or mouse button). For example, if holding some key should move some 3D object, you should do something like: if HandleInput then begin if Container.Pressed[keyArrowRight] then begin Transform.Position := Transform.Position + Vector3(SecondsPassed * 10, 0, 0); HandleInput := false; end; end;
Instead of directly using a key code, consider also using TInputShortcut that makes the input key nicely configurable. See engine tutorial about handling inputs. Multiplying movement by SecondsPassed makes your operation frame-rate independent. Object will move by 10 units in a second, regardless of how many FPS your game has. The code related to HandleInput is important if you write a generally-useful control that should nicely cooperate with all other controls, even when placed on top of them or under them. The correct approach is to only look at pressed keys/mouse buttons if HandleInput is Note that to handle a single press / release (like "switch light on when pressing a key") you should rather use Press and Release methods. Use this method only for continuous handling (like "holding this key makes the light brighter and brighter"). To understand why such HandleInput approach is needed, realize that the "Update" events are called differently than simple mouse and key events like "Press" and "Release". "Press" and "Release" events return whether the event was somehow "handled", and the container passes them only to the controls under the mouse (decided by TCastleUserInterface.CapturesEventsAtPosition). And as soon as some control says it "handled" the event, other controls (even if under the mouse) will not receive the event. This approach is not suitable for Update events. Some controls need to do the Update job all the time, regardless of whether the control is under the mouse and regardless of what other controls already did. So all controls (well, all controls that exist, in case of TCastleUserInterface, see TCastleUserInterface.Exists) receive Update calls. So the "handled" status is passed through HandleInput. If a control is not under the mouse, it will receive HandleInput = | |
| Public | procedure VisibleChange(const Changes: TCastleUserInterfaceChanges; const ChangeInitiatedByChildren: boolean = false); override; |
|
This item has no description. Showing description inherited from TCastleUserInterface.VisibleChange. Called always when something important inside this control (or it's children) changed. To be more precise, this is called when something mentioned among the TCastleUserInterfaceChange enumerated items changed. This is always called with Changes <> [] (non-empty set). | |
| Public | procedure EditorAllowResize(out ResizeWidth, ResizeHeight: Boolean; out Reason: String); override; |
|
This item has no description. Showing description inherited from TCastleUserInterface.EditorAllowResize. Override this to prevent resizing some dimension in CGE editor. | |
| Public | function PropertySections(const PropertyName: String): TPropertySections; override; |
|
This item has no description. Showing description inherited from TCastleComponent.PropertySections. Section where to show property in the editor. | |
| Public | procedure DoClick; virtual; |
|
Called when user clicks the button. In this class, simply calls OnClick callback. | |
| Public | procedure SetFocused(const Value: boolean); override; |
|
This item has no description. Showing description inherited from TCastleUserInterface.SetFocused. Called when this control becomes or stops being focused, that is: under the mouse cursor and will receive events. This updates Focused property. This also calls OnInternalMouseEnter / OnInternalMouseLeave. | |
Properties
| Public | property NonVisualComponents [const Index: Integer]: TComponent read GetNonVisualComponents; |
|
Components added by AddNonVisualComponent. | |
| Public | property IsLoading: Boolean read FIsLoading; |
|
Is the component during deserialization now. Note: We can't use | |
| Public | property OnVisibleChange: TCastleUserInterfaceChangeEvent
read FOnVisibleChange write FOnVisibleChange; |
|
Called always when something important inside this control (or it's children) changed. See VisibleChange for details about when and how this is called. Be careful when handling this event. Various changes may cause this, so be prepared to handle it at any moment, even in the middle when UI control is changing. It may also occur very often. It's usually safest to only set a boolean flag like "something should be recalculated" when this event happens, and do the actual recalculation later. | |
| Public | property Container: TCastleContainer read FContainer; |
|
Container of this control. When adding control to container's Controls list (like TCastleWindow.Controls) container will automatically set itself here, and when removing from container this will be changed back to May be | |
| Public | property OnCursorChange: TNotifyEvent
read FOnCursorChange write FOnCursorChange; deprecated 'use OnVisibleChange (or override VisibleChange) and watch for Changes that include chCursor'; |
|
Warning: this symbol is deprecated: use OnVisibleChange (or override VisibleChange) and watch for Changes that include chCursor Event called when the Cursor property changes. This event is, in normal circumstances, used by the Container, so you should not use it in your own programs. | |
| Public | property ExclusiveEvents: boolean
read FExclusiveEvents write FExclusiveEvents default true; deprecated 'do not use this; supporting this property was complicated and had no real benefit; everything now works as if ExclusiveEvents=true, always'; |
|
Warning: this symbol is deprecated: do not use this; supporting this property was complicated and had no real benefit; everything now works as if ExclusiveEvents=true, always
Should we disable further mouse / keys handling for events that we already handled in this control. If This means that events will not be simultaneously handled by both this control and some other (or camera or normal window callbacks), which is usually more sensible, but sometimes somewhat limiting. | |
| Public | property Controls [const Index: Integer]: TCastleUserInterface read GetControls write SetControls; |
|
This item has no description. | |
| Public | property GetExists: Boolean read FExists; deprecated 'use Exists'; |
|
Warning: this symbol is deprecated: use Exists This item has no description. | |
| Public | property GLInitialized: boolean read FGLInitialized default false; |
|
This item has no description. | |
| Public | property Focused: boolean read FFocused write SetFocused; |
|
See SetFocused. | |
| Public | property Parent: TCastleUserInterface read FParent ; |
|
Visual parent control. This control is rendered within the parent, and it's anchors and coordinates are relative to the parent. Parent may be Note that this property doesn't have a setter, as it could be confusing: the order in which children are inserted into parent sometimes matters, for back-and-front order. If you want to change the parent, you can use code like this: if Control.Parent <> nil then Control.Parent.RemoveControl(Control); if NewParent <> nil then NewParent.InsertFront(Control); // or InsertBack, as InsertControl... | |
| Public | property FloatWidth: Single read FWidth write SetWidth stored false; deprecated 'use Width'; |
|
Warning: this symbol is deprecated: use Width This item has no description. | |
| Public | property FloatHeight: Single read FHeight write SetHeight stored false; deprecated 'use Height'; |
|
Warning: this symbol is deprecated: use Height This item has no description. | |
| Public | property AnchorDelta: TVector2 read FTranslation write SetTranslation; deprecated 'use Translation'; |
|
Warning: this symbol is deprecated: use Translation Position of the control, relative to the anchor at parent (by default, relative to left-bottom corner of the parent). | |
| Public | property Translation: TVector2 read FTranslation write SetTranslation; |
|
Position of the control, relative to the anchor at parent (by default, relative to left-bottom corner of the parent). | |
| Public | property KeepInFront: boolean read FKeepInFront write FKeepInFront
default false; |
|
Keep the control in front of other controls (with TODO: Do not change this property while the control is already a child of something. | |
| Public | property BorderColor: TCastleColor read FBorderColor write SetBorderColor; |
|
Color of the Border, by default completely transparent black. | |
| Public | property HasHorizontalAnchor: boolean
read FHasHorizontalAnchor write FHasHorizontalAnchor stored false; deprecated 'this property does not do anything anymore, anchors are always active'; |
|
Warning: this symbol is deprecated: this property does not do anything anymore, anchors are always active This item has no description. | |
| Public | property HasVerticalAnchor: boolean
read FHasVerticalAnchor write FHasVerticalAnchor stored false; deprecated 'this property does not do anything anymore, anchors are always active'; |
|
Warning: this symbol is deprecated: this property does not do anything anymore, anchors are always active This item has no description. | |
| Public | property HorizontalAnchorDelta: Single
read GetHorizontalAnchorDelta write SetHorizontalAnchorDelta default 0; deprecated 'use Translation.X'; |
|
Warning: this symbol is deprecated: use Translation.X Delta between our border and parent. See also
| |
| Public | property VerticalAnchorDelta: Single
read GetVerticalAnchorDelta write SetVerticalAnchorDelta default 0; deprecated 'use Translation.Y'; |
|
Warning: this symbol is deprecated: use Translation.Y Delta between our border and parent. See also
| |
| Public | property Visible: Boolean read FVisible; |
|
Is the control possibly visible. This is always | |
| Public | property EnableUIScaling: boolean
read FEnableUIScaling write SetEnableUIScaling default true; |
|
Enable or disable UI scaling for this particular control. See more about UI scaling on TCastleContainer.UIScaling and TCastleUserInterface.UIScale. Setting this to Note that this does not work recursively, i.e. it does not affect the children of this control. Setting this to The use-cases for changing this property to "false" are very rare. Usually you should use UI scaling for 100% of your UI. | |
| Public | property CapturesEvents: boolean read FCapturesEvents write FCapturesEvents
default true; |
|
Capture input events (keyboard, mouse, joystick). If The only exception is when this control is set as TCastleContainer.ForceCaptureInput. In this case, the control will receive inputs. In other words, TCastleContainer.ForceCaptureInput overrides the intent of this property. This property may be replaced by something like "CaptureInput" or just universal "Enabled" in the future. | |
| Public | property OnInternalMouseEnter: TUiNotifyEvent
read FOnInternalMouseEnter write FOnInternalMouseEnter; |
|
Called when control starts being under the mouse cursor and will receive events. See SetFocused, this is called when Focused changes from This is called "Internal" now, because we do not guarantee it's 100% always paired with OnInternalMouseLeave. A different approach to this may be done in the future releases. | |
| Public | property OnInternalMouseLeave: TUiNotifyEvent
read FOnInternalMouseLeave write FOnInternalMouseLeave; |
|
Called when control stops being under the mouse cursor and will receive events. See SetFocused, this is called when Focused changes from This is called "Internal" now, because we do not guarantee it's 100% always paired with OnInternalMouseEnter. A different approach to this may be done in the future releases. | |
| Published | property Cursor: TMouseCursor read FCursor write SetCursor default mcDefault; |
|
Mouse cursor over this control. When user moves mouse over the Container, the currently focused (topmost under the cursor) control determines the mouse cursor look. | |
| Published | property OnUpdate: TUiUpdateEvent read FOnUpdate write FOnUpdate; |
|
Event that occurs continuously on each control. See Update for details. | |
| Published | property OnPress: TUiPressReleaseEvent read FOnPress write FOnPress; |
|
An input (key, mouse button, mouse wheel) was pressed. See Press for details. | |
| Published | property OnRelease: TUiPressReleaseEvent read FOnRelease write FOnRelease; |
|
An input (key, mouse button, mouse wheel) was released. See Release for details. | |
| Published | property OnMotion: TUiMotionEvent read FOnMotion write FOnMotion; |
|
Pointer (mouse or finger) moved. See Motion for details. | |
| Published | property OnRender: TUiNotifyEvent read FOnRender write FOnRender; |
|
Control is being displayed. See Render for details. This event it called after the Render method of this control finished but before we started rendering children. | |
| Published | property Exists: boolean read FExists write SetExists default true; |
|
Not existing control is not visible, it doesn't receive input and generally doesn't exist from the point of view of user. This is mostly equivalent to just removing this control from parent list. Non-existing controls still receive GLContextOpen, GLContextClose, Resize events. | |
| Published | property Left: Single read FLeft write SetLeft stored false default 0; deprecated 'use Translation.X'; |
|
Warning: this symbol is deprecated: use Translation.X Position from the left side of the parent control. It's usually better to use anchors instead of this property. For example, instead of setting Note that the effects of this property and Translation.X are summed, if you set both. We advise to leave Left as zero and just use anchors in new code. | |
| Published | property Bottom: Single read FBottom write SetBottom default 0; deprecated 'use Translation.Y'; |
|
Warning: this symbol is deprecated: use Translation.Y Position from the bottom side of the parent control. It's usually better to use anchors instead of this property. For example, instead of setting Note that the effects of this property and Translation.Y are summed, if you set both. We advise to leave Bottom as zero and just use anchors in new code. | |
| Published | property FullSize: boolean read FFullSize write SetFullSize default false; |
|
When See also
| |
| Published | property Width: Single read FWidth write SetWidth default DefaultWidth; |
|
These properties determine the control size. See the EffectiveRect documentation for details how the size is calculated.
See also
| |
| Published | property Height: Single read FHeight write SetHeight default DefaultHeight; |
|
This item has no description. | |
| Published | property WidthFraction: Single read FWidthFraction write SetWidthFraction default 0.0; |
|
This item has no description. | |
| Published | property HeightFraction: Single read FHeightFraction write SetHeightFraction default 0.0; |
|
This item has no description. | |
| Published | property AutoSizeToChildren: Boolean
read FAutoSizeToChildren write SetAutoSizeToChildren default false; |
|
Adjust size to encompass all the children. The properties FullSize, Width, Height are ignored in this case. Our Left and Bottom still matter. Our size is adjusted to all existing children sizes and positions. We add AutoSizeToChildrenPaddingTop to the resulting height, and AutoSizeToChildrenPaddingRight to the resulting width. | |
| Published | property AutoSizeToChildrenPaddingRight: Single
read FAutoSizeToChildrenPaddingRight
write SetAutoSizeToChildrenPaddingRight default 0; |
|
Padding added when AutoSizeToChildren is used. TODO: Should be AutoSizeToChildrenPaddingHorizontal, there's nothing that makes it specific to "right" or "left" side now. | |
| Published | property AutoSizeToChildrenPaddingTop: Single
read FAutoSizeToChildrenPaddingTop
write SetAutoSizeToChildrenPaddingTop default 0; |
|
Padding added when AutoSizeToChildren is used. TODO: Should be AutoSizeToChildrenPaddingVertical, there's nothing that makes it specific to "top" or "bottom" side now. | |
| Published | property HorizontalAnchorSelf: THorizontalPosition
read FHorizontalAnchorSelf write SetHorizontalAnchorSelf default hpLeft; |
|
Which our border to align with parent. See also
| |
| Published | property HorizontalAnchorParent: THorizontalPosition
read FHorizontalAnchorParent write SetHorizontalAnchorParent default hpLeft; |
|
Which parent border is aligned to our HorizontalAnchorSelf border. See also
| |
| Published | property VerticalAnchorSelf: TVerticalPosition
read FVerticalAnchorSelf write SetVerticalAnchorSelf default vpBottom; |
|
Which our border to align with parent. See also
| |
| Published | property VerticalAnchorParent: TVerticalPosition
read FVerticalAnchorParent write SetVerticalAnchorParent default vpBottom; |
|
Which parent border is aligned to our VerticalAnchorSelf border. See also
| |
| Published | property Culling: Boolean read FCulling write SetCulling default false; |
|
Optimize rendering and event processing by checking whether the control can be visible. The visibility is checked by looking at container rectangle, and all possible clipping parents (set by TCastleScrollView, or any other control with ClipChildren). This is useful for UI controls that have expensive rendering or other events (e.g. they do something non-trivial in Render or RenderOverChildren, or they include a lot of children controls). And they may be placed off-screen, or they may be outside of a parent with clipping, which is often the case when the parent is TCastleScrollView. | |
| Published | property ClipChildren: Boolean read FClipChildren write SetClipChildren default false; |
|
Clip the rendering of children. By default this is When this property is | |
| Published | property Border: TBorder read FBorder; |
|
Border (by default transparent) of the control. Border adds a space from the control content (drawn within RenderRect) to the control rectangle (returned by RenderRectWithBorder) (scaled), or EffectiveRect (unscaled) and friends). It is transparent by default, but you can change it by BorderColor. Border works always, regardless of FullSize or AutoSizeToChildren. One obvious use-case is to use this for visual space (empty space or a colorful frame, separating this control from the rest). Another use-case is to reserve a predictable space for as additional (sibling) control within the same parent. E.g. you can set FullSize=true and Border.Top=100, and this way there is always a strip with Height=100 at the top of the parent, where you can insert another control (with Height=100, anchored to the top). | |
| Published | property CustomTheme: TCastleTheme read FCustomTheme write SetCustomTheme; |
|
Use a custom instance of TCastleTheme to determine the look of this control. | |
| Published | property TooltipControl: TCastleUserInterface read FTooltipControl write SetTooltipControl; |
|
If set, the indicated control will act as a tooltip: we will make it existing when we should show the tooltip for this control, we will make it no longer existing when the tooltip for this should be hidden. Initially the If The visual parent of | |
| Published | property EditorSelectOnHover: Boolean read FEditorSelectOnHover write FEditorSelectOnHover default true; |
|
Select the UI (hover, select on click) at design-time when the mouse is over rectangle of this UI. This affects operation in the editor, and when using the inspector (press F8 at run-time, when the application is build in debug mode). It's by default Note that hovering over children of UI with | |
| Published | property BorderColorPersistent: TCastleColorPersistent read FBorderColorPersistent ; |
|
BorderColor that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write BorderColor directly. See also
Source: ui/auto_generated_persistent_vectors/tcastleuserinterface_persistent_vectors.inc (line 37). | |
| Published | property TranslationPersistent: TCastleVector2Persistent read FTranslationPersistent ; |
|
Translation that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write Translation directly. See also
Source: ui/auto_generated_persistent_vectors/tcastleuserinterface_persistent_vectors.inc (line 105). | |
| Public | property OwnsCustomFont: boolean
read FOwnsCustomFont write FOwnsCustomFont default false; deprecated 'use TCastleAbstractFont (inherited from TComponent) owner mechanism'; |
|
Warning: this symbol is deprecated: use TCastleAbstractFont (inherited from TComponent) owner mechanism This item has no description. | |
| Public | property SmallFont: boolean read FSmallFont write SetSmallFont default false; deprecated 'use "FontScale := 0.5" or "CustomFont := MySmalFont" instead of "SmallFont := true", this is more flexible'; |
|
Warning: this symbol is deprecated: use "FontScale := 0.5" or "CustomFont := MySmalFont" instead of "SmallFont := true", this is more flexible Use smaller font. Right now this just says to scale font by 0.5. | |
| Public | property OutlineColor: TCastleColor read FOutlineColor write SetOutlineColor; |
|
Outline color, used only if Outline <> 0. Default is black. See also
| |
| Published | property Tooltip: string read FTooltip write FTooltip; |
|
Tooltip string, displayed when user hovers the mouse over a control. Note that you can override TCastleUserInterface.TooltipExists and TCastleUserInterface.TooltipRender to customize the tooltip drawing. | |
| Published | property CustomFont: TCastleAbstractFont
read FCustomFont write SetCustomFont; |
|
Font used to render text of this control. When this is | |
| Published | property FontSize: Single read FFontSize write SetFontSize default 0.0; |
|
Use given font size when drawing. Leave at default zero to use the default size of the current font. | |
| Published | property FontScale: Single read FFontScale write SetFontScale default 1.0; |
|
Scale the font. This additionally scales the font defined by all other properties of this class, thus you can use it to reliably scale the font (regardless if you use CustomFont or not, regardless if you set FontSize or not). | |
| Published | property Outline: Cardinal read FOutline write SetOutline default 0; |
|
Outline size around the font. Note that the current implementation is very simple, it will only look sensible for small outline values (like 1 or 2). See TCastleAbstractFont.Outline for more details. Specifying a non-zero outline for a label overrides the default outline settings for the current font. By default, fonts do not have an outline. TODO: UI scaling (TCastleContainer.UIScaling) doesn't affect outline size now. See also
| |
| Published | property OutlineHighQuality: boolean
read FOutlineHighQuality write SetOutlineHighQuality default false; |
|
Optionally force better outline quality. Used only if Outline <> 0. High quality outline looks better, but is about 2x more expensive to draw. See also
| |
| Published | property OutlineColorPersistent: TCastleColorPersistent read FOutlineColorPersistent ; |
|
OutlineColor that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write OutlineColor directly. See also
| |
| Public | property TintPressed : TCastleColor read FTintPressed write FTintPressed; |
|
Color tint when the button is pressed (regardless if enabled or disabled). Opaque white by default. | |
| Public | property TintDisabled: TCastleColor read FTintDisabled write FTintDisabled; |
|
Color tint when the button is disabled (and not pressed). Opaque white by default. | |
| Public | property TintFocused : TCastleColor read FTintFocused write FTintFocused; |
|
Color tint when the button is focused. Opaque white by default. | |
| Public | property TintNormal : TCastleColor read FTintNormal write FTintNormal; |
|
Color tint when the button is enabled, but neither pressed nor focused. Opaque white by default. | |
| Public | property CustomTextColor: TCastleColor read FCustomTextColor write FCustomTextColor; |
|
Text color to use if CustomTextColorUse is | |
| Public | property CustomColorPressed: TCastleColor read FCustomColorPressed write SetCustomColorPressed; |
|
Button colors used when CustomBackground is By default they are all transparent black, so actually the button is completely transparent in this case. They are affected by tint (see TintPressed, TintDisabled, TintFocused, TintNormal). The tint color is simply multiplied component-wise with these colors. By default all tint colors are opaque white, so the multiplication by tint actually doesn't change anything. | |
| Public | property CustomColorDisabled: TCastleColor read FCustomColorDisabled write SetCustomColorDisabled; |
|
This item has no description. | |
| Public | property CustomColorFocused: TCastleColor read FCustomColorFocused write SetCustomColorFocused; |
|
This item has no description. | |
| Public | property CustomColorNormal: TCastleColor read FCustomColorNormal write SetCustomColorNormal; |
|
This item has no description. | |
| Published | property MinImageWidth: Single read FMinImageWidth write FMinImageWidth default 0; |
|
Auto-size routines (see AutoSize) may treat the image like always having at least these minimal sizes. Even if the Image is empty ( | |
| Published | property MinImageHeight: Single read FMinImageHeight write FMinImageHeight default 0; |
|
This item has no description. | |
| Published | property TextAlignment: THorizontalPosition
read FTextAlignment write SetTextAlignment default DefaultTextAlignment; |
|
For multi-line Caption, the horizontal alignment of the lines. | |
| Published | property Alignment: THorizontalPosition
read FAlignment write SetAlignment default hpMiddle; |
|
Horizontal alignment of the text+image within button area, useful in case you don't use AutoSize. We align text+image within the available area inside the button (which is determined by button size, without paddings determined by PaddingHorizontal, PaddingVertical). | |
| Published | property VerticalAlignment: TVerticalPosition
read FVerticalAlignment write SetVerticalAlignment default vpMiddle; |
|
Vertical alignment of the text+image within button area, useful in case you don't use AutoSize. We align text+image within the available area inside the button (which is determined by button size, without paddings determined by PaddingHorizontal, PaddingVertical). | |
| Published | property LineSpacing: Single read FLineSpacing write SetLineSpacing
default DefaultLineSpacing; |
|
For multi-line Caption, the extra spacing between lines. May also be negative to squeeze lines tighter. | |
| Published | property Html: boolean read FHtml write SetHtml default false; |
|
Enable HTML tags in the Caption. This allows to easily change colors or use bold, italic text. See the example examples/fonts/html_text.lpr and examples/fonts/html_text_demo.html for a demo of what HTML tags can do. See TCastleAbstractFont.PrintStrings documentation for a list of support HTML markup. Note that to see the bold/italic font variants in the HTML markup, you need to set the font to be TCastleFontFamily with bold/italic variants. See the example mentioned above, examples/fonts/html_text.lpr, for a code how to do it. | |
| Published | property CustomBackground: boolean read FCustomBackground write FCustomBackground default false; |
|
Use custom background images. If
They are affected by tint (see TintPressed, TintDisabled, TintFocused, TintNormal). | |
| Published | property Image: TCastleImagePersistent read FImage; |
|
Optional image displayed on the button. | |
| Published | property ImageScale: Single read FImageScale write SetImageScale default 1.0; |
|
Scaling of Image. | |
| Published | property CustomBackgroundPressed: TCastleImagePersistent read FCustomBackgroundPressed; |
|
Background image on the pressed button. See CustomBackground for details. | |
| Published | property CustomBackgroundDisabled: TCastleImagePersistent read FCustomBackgroundDisabled; |
|
Background image on the disabled button. See CustomBackground for details. | |
| Published | property CustomBackgroundFocused: TCastleImagePersistent read FCustomBackgroundFocused; |
|
Background image on the focused button. See CustomBackground for details. | |
| Published | property CustomBackgroundNormal: TCastleImagePersistent read FCustomBackgroundNormal; |
|
Background image on the normal button. See CustomBackground for details. | |
| Published | property CustomTextColorUse: boolean read FCustomTextColorUse write FCustomTextColorUse default false; |
|
Should we use custom text color in CustomTextColor instead of | |
| Published | property PaddingHorizontal: Single
read FPaddingHorizontal write SetPaddingHorizontal default DefaultPaddingHorizontal; |
|
Horizontal distance between the text or Image and the button border. | |
| Published | property PaddingVertical: Single
read FPaddingVertical write SetPaddingVertical default DefaultPaddingVertical; |
|
Vertical distance between the text or Image and the button border. | |
| Published | property AutoSize: boolean read FAutoSize write SetAutoSize default true; |
|
When Width is auto-calculated only when If needed, you can query the resulting button size with the standard TCastleUserInterface methods like TCastleUserInterface.EffectiveWidth and TCastleUserInterface.EffectiveHeight. Note that they may not be available before the button is actually added to the container, and the container size is initialized (we need to know the size of container, for UI scaling to determine the font size). | |
| Published | property AutoSizeWidth: boolean read FAutoSizeWidth write SetAutoSizeWidth default true; |
|
This item has no description. | |
| Published | property AutoSizeHeight: boolean read FAutoSizeHeight write SetAutoSizeHeight default true; |
|
This item has no description. | |
| Published | property MinWidth: Single read FMinWidth write SetMinWidth default 0; |
|
When auto-size is in effect, these properties may force a minimal width/height of the button. This is useful if you want to use auto-size (to make sure that the content fits inside), but you want to force filling some space. | |
| Published | property MinHeight: Single read FMinHeight write SetMinHeight default 0; |
|
This item has no description. | |
| Published | property OnClick: TNotifyEvent read FOnClick write FOnClick; |
|
Event triggered when the button is clicked. | |
| Published | property Caption: String read FCaption write SetCaption; |
|
Caption to display on the button. The text may be multiline (use the LineEnding or NL constants to mark newlines). | |
| Published | property CaptionTranslate: Boolean read FCaptionTranslate write FCaptionTranslate default true; |
|
Should the Caption be localized (translated into other languages). Determines if the property is enumerated by TCastleComponent.TranslateProperties, which affects the rest of localization routines. | |
| Published | property Toggle: boolean read FToggle write FToggle default false; |
|
Can the button be permanently pressed. Good for making a button behave like a checkbox, that is indicate a boolean state. When Toggle is | |
| Published | property Pressed: boolean read FPressed write SetPressed default false; |
|
Is the button pressed down. If Toggle is When not Toggle, this property isn't really useful to you. The pressed state is automatically managed then to visualize user clicks. In this case, you can read this property, but you cannot reliably set it. | |
| Published | property ImageLayout: TCastleButtonImageLayout
read FImageLayout write SetImageLayout default ilLeft; |
|
Where the Image is drawn on the button. | |
| Published | property ImageMargin: Single read FImageMargin write SetImageMargin
default DefaultImageMargin; |
| Published | property Enabled: boolean read FEnabled write SetEnabled default true; |
|
Enabled button can be focused and clicked, is not grayed-out. | |
| Published | property EnableParentDragging: boolean
read FEnableParentDragging write FEnableParentDragging default false; |
|
Enable to drag a parent control, for example to drag a TCastleScrollView that contains this button. To do this, you need to turn on TCastleScrollView.EnableDragging, and set | |
| Published | property TintPressedPersistent: TCastleColorPersistent read FTintPressedPersistent ; |
|
TintPressed that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write TintPressed directly. See also
Source: ui/auto_generated_persistent_vectors/tcastlebutton_persistent_vectors.inc (line 37). | |
| Published | property TintDisabledPersistent: TCastleColorPersistent read FTintDisabledPersistent ; |
|
TintDisabled that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write TintDisabled directly. See also
Source: ui/auto_generated_persistent_vectors/tcastlebutton_persistent_vectors.inc (line 105). | |
| Published | property TintFocusedPersistent: TCastleColorPersistent read FTintFocusedPersistent ; |
|
TintFocused that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write TintFocused directly. See also
Source: ui/auto_generated_persistent_vectors/tcastlebutton_persistent_vectors.inc (line 173). | |
| Published | property TintNormalPersistent: TCastleColorPersistent read FTintNormalPersistent ; |
|
TintNormal that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write TintNormal directly. See also
Source: ui/auto_generated_persistent_vectors/tcastlebutton_persistent_vectors.inc (line 241). | |
| Published | property CustomTextColorPersistent: TCastleColorPersistent read FCustomTextColorPersistent ; |
|
CustomTextColor that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write CustomTextColor directly. See also
Source: ui/auto_generated_persistent_vectors/tcastlebutton_persistent_vectors.inc (line 309). | |
| Published | property CustomColorPressedPersistent: TCastleColorPersistent read FCustomColorPressedPersistent ; |
|
CustomColorPressed that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write CustomColorPressed directly. See also
Source: ui/auto_generated_persistent_vectors/tcastlebutton_persistent_vectors.inc (line 377). | |
| Published | property CustomColorDisabledPersistent: TCastleColorPersistent read FCustomColorDisabledPersistent ; |
|
CustomColorDisabled that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write CustomColorDisabled directly. See alsoSource: ui/auto_generated_persistent_vectors/tcastlebutton_persistent_vectors.inc (line 445). | |
| Published | property CustomColorFocusedPersistent: TCastleColorPersistent read FCustomColorFocusedPersistent ; |
|
CustomColorFocused that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write CustomColorFocused directly. See alsoSource: ui/auto_generated_persistent_vectors/tcastlebutton_persistent_vectors.inc (line 513). | |
| Published | property CustomColorNormalPersistent: TCastleColorPersistent read FCustomColorNormalPersistent ; |
|
CustomColorNormal that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write CustomColorNormal directly. See alsoSource: ui/auto_generated_persistent_vectors/tcastlebutton_persistent_vectors.inc (line 581). | |
Generated by PasDoc 0.17.0.snapshot.