Class TCastleButton
Unit
Declaration
type TCastleButton = class(TCastleUserInterfaceFont)
Description
Clickable button.
This is TCastleUserInterface descendant, so to use it just add it to the TCastleWindow.Controls or TCastleControl.Controls list. You will also usually want to adjust position (TCastleButton.Left, TCastleButton.Bottom), TCastleButton.Caption, and assign TCastleButton.OnClick (or ovevrride TCastleButton.DoClick).
Hierarchy
- TObject
- TPersistent
- TComponent
- TCastleComponent
- TCastleUserInterface
- TCastleUserInterfaceFont
- TCastleButton
Overview
Fields
nested const DefaultImageMargin = 10; |
|
nested const DefaultPaddingHorizontal = 10; |
|
nested const DefaultPaddingVertical = 10; |
|
nested const DefaultLineSpacing = 2; |
|
nested const DefaultTextAlignment = hpMiddle; |
Methods
procedure SetPressed(const Value: boolean); virtual; |
|
procedure UIScaleChanged; override; |
|
procedure PreferredSize(var PreferredWidth, PreferredHeight: Single); override; |
|
function GetInternalText: String; override; |
|
procedure SetInternalText(const Value: String); override; |
|
procedure TranslateProperties(const TranslatePropertyEvent: TTranslatePropertyEvent); override; |
|
constructor Create(AOwner: TComponent); override; |
|
destructor Destroy; override; |
|
procedure Render; override; |
|
function Press(const Event: TInputPressRelease): boolean; override; |
|
function Release(const Event: TInputPressRelease): boolean; override; |
|
function Motion(const Event: TInputMotion): boolean; override; |
|
procedure FontChanged; override; |
|
procedure VisibleChange(const Changes: TCastleUserInterfaceChanges; const ChangeInitiatedByChildren: boolean = false); override; |
|
procedure EditorAllowResize(out ResizeWidth, ResizeHeight: Boolean; out Reason: String); override; |
|
function PropertySections(const PropertyName: String): TPropertySections; override; |
|
procedure DoClick; virtual; |
|
procedure SetFocused(const Value: boolean); override; |
Properties
property TintPressed : TCastleColor read FTintPressed write FTintPressed; |
|
property TintDisabled: TCastleColor read FTintDisabled write FTintDisabled; |
|
property TintFocused : TCastleColor read FTintFocused write FTintFocused; |
|
property TintNormal : TCastleColor read FTintNormal write FTintNormal; |
|
property CustomTextColor: TCastleColor read FCustomTextColor write FCustomTextColor; |
|
property CustomColorPressed: TCastleColor read FCustomColorPressed write SetCustomColorPressed; |
|
property CustomColorDisabled: TCastleColor read FCustomColorDisabled write SetCustomColorDisabled; |
|
property CustomColorFocused: TCastleColor read FCustomColorFocused write SetCustomColorFocused; |
|
property CustomColorNormal: TCastleColor read FCustomColorNormal write SetCustomColorNormal; |
|
property MinImageWidth: Single read FMinImageWidth write FMinImageWidth default 0; |
|
property MinImageHeight: Single read FMinImageHeight write FMinImageHeight default 0; |
|
property TextAlignment: THorizontalPosition
read FTextAlignment write SetTextAlignment default DefaultTextAlignment; |
|
property Alignment: THorizontalPosition
read FAlignment write SetAlignment default hpMiddle; |
|
property VerticalAlignment: TVerticalPosition
read FVerticalAlignment write SetVerticalAlignment default vpMiddle; |
|
property LineSpacing: Single read FLineSpacing write SetLineSpacing
default DefaultLineSpacing; |
|
property Html: boolean read FHtml write SetHtml default false; |
|
property CustomBackground: boolean read FCustomBackground write FCustomBackground default false; |
|
property Image: TCastleImagePersistent read FImage; |
|
property ImageScale: Single read FImageScale write SetImageScale default 1.0; |
|
property CustomBackgroundPressed: TCastleImagePersistent read FCustomBackgroundPressed; |
|
property CustomBackgroundDisabled: TCastleImagePersistent read FCustomBackgroundDisabled; |
|
property CustomBackgroundFocused: TCastleImagePersistent read FCustomBackgroundFocused; |
|
property CustomBackgroundNormal: TCastleImagePersistent read FCustomBackgroundNormal; |
|
property CustomTextColorUse: boolean read FCustomTextColorUse write FCustomTextColorUse default false; |
|
property PaddingHorizontal: Single
read FPaddingHorizontal write SetPaddingHorizontal default DefaultPaddingHorizontal; |
|
property PaddingVertical: Single
read FPaddingVertical write SetPaddingVertical default DefaultPaddingVertical; |
|
property AutoSize: boolean read FAutoSize write SetAutoSize default true; |
|
property AutoSizeWidth: boolean read FAutoSizeWidth write SetAutoSizeWidth default true; |
|
property AutoSizeHeight: boolean read FAutoSizeHeight write SetAutoSizeHeight default true; |
|
property MinWidth: Single read FMinWidth write SetMinWidth default 0; |
|
property MinHeight: Single read FMinHeight write SetMinHeight default 0; |
|
property OnClick: TNotifyEvent read FOnClick write FOnClick; |
|
property Caption: string read FCaption write SetCaption; |
|
property CaptionTranslate: Boolean read FCaptionTranslate write FCaptionTranslate default true; |
|
property Toggle: boolean read FToggle write FToggle default false; |
|
property Pressed: boolean read FPressed write SetPressed default false; |
|
property ImageLayout: TCastleButtonImageLayout
read FImageLayout write SetImageLayout default ilLeft; |
|
property ImageMargin: Single read FImageMargin write SetImageMargin
default DefaultImageMargin; |
|
property Enabled: boolean read FEnabled write SetEnabled default true; |
|
property EnableParentDragging: boolean
read FEnableParentDragging write FEnableParentDragging default false; |
|
property TintPressedPersistent: TCastleColorPersistent read FTintPressedPersistent ; |
|
property TintDisabledPersistent: TCastleColorPersistent read FTintDisabledPersistent ; |
|
property TintFocusedPersistent: TCastleColorPersistent read FTintFocusedPersistent ; |
|
property TintNormalPersistent: TCastleColorPersistent read FTintNormalPersistent ; |
|
property CustomTextColorPersistent: TCastleColorPersistent read FCustomTextColorPersistent ; |
|
property CustomColorPressedPersistent: TCastleColorPersistent read FCustomColorPressedPersistent ; |
|
property CustomColorDisabledPersistent: TCastleColorPersistent read FCustomColorDisabledPersistent ; |
|
property CustomColorFocusedPersistent: TCastleColorPersistent read FCustomColorFocusedPersistent ; |
|
property CustomColorNormalPersistent: TCastleColorPersistent read FCustomColorNormalPersistent ; |
Description
Fields
nested const DefaultImageMargin = 10; |
|
nested const DefaultPaddingHorizontal = 10; |
|
nested const DefaultPaddingVertical = 10; |
|
nested const DefaultLineSpacing = 2; |
|
nested const DefaultTextAlignment = hpMiddle; |
|
Methods
procedure SetPressed(const Value: boolean); virtual; |
|
procedure UIScaleChanged; override; |
|
procedure PreferredSize(var PreferredWidth, PreferredHeight: Single); override; |
|
function GetInternalText: String; override; |
|
procedure SetInternalText(const Value: String); override; |
|
procedure TranslateProperties(const TranslatePropertyEvent: TTranslatePropertyEvent); override; |
|
constructor Create(AOwner: TComponent); override; |
|
destructor Destroy; override; |
|
procedure Render; override; |
|
function Press(const Event: TInputPressRelease): boolean; override; |
|
function Release(const Event: TInputPressRelease): boolean; override; |
|
function Motion(const Event: TInputMotion): boolean; override; |
|
procedure FontChanged; override; |
|
procedure VisibleChange(const Changes: TCastleUserInterfaceChanges; const ChangeInitiatedByChildren: boolean = false); override; |
|
procedure EditorAllowResize(out ResizeWidth, ResizeHeight: Boolean; out Reason: String); override; |
|
function PropertySections(const PropertyName: String): TPropertySections; override; |
|
procedure DoClick; virtual; |
|
Called when user clicks the button. In this class, simply calls OnClick callback. |
procedure SetFocused(const Value: boolean); override; |
|
Properties
property TintPressed : TCastleColor read FTintPressed write FTintPressed; |
|
Color tint when button is pressed (regardless if enabled or disabled). Opaque white by default. |
property TintDisabled: TCastleColor read FTintDisabled write FTintDisabled; |
|
Color tint when button is disabled (and not pressed). Opaque white by default. |
property TintFocused : TCastleColor read FTintFocused write FTintFocused; |
|
Color tint when button is focused. Opaque white by default. |
property TintNormal : TCastleColor read FTintNormal write FTintNormal; |
|
Color tint when button is enabled, but neither pressed nor focused. Opaque white by default. |
property CustomTextColor: TCastleColor read FCustomTextColor write FCustomTextColor; |
|
Text color to use if CustomTextColorUse is |
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. |
property CustomColorDisabled: TCastleColor read FCustomColorDisabled write SetCustomColorDisabled; |
|
property CustomColorFocused: TCastleColor read FCustomColorFocused write SetCustomColorFocused; |
|
property CustomColorNormal: TCastleColor read FCustomColorNormal write SetCustomColorNormal; |
|
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 ( |
property MinImageHeight: Single read FMinImageHeight write FMinImageHeight default 0; |
|
property TextAlignment: THorizontalPosition
read FTextAlignment write SetTextAlignment default DefaultTextAlignment; |
|
For multi-line Caption, the horizontal alignment of the lines. |
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). |
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). |
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. |
property Html: boolean read FHtml write SetHtml default false; |
|
Enable See the example examples/fonts/html_text.lpr and examples/fonts/html_text_demo.html for a demo of what Note that to see the bold/italic font variants in the |
property CustomBackground: boolean read FCustomBackground write FCustomBackground default false; |
|
Use custom background images. If
They are affected by tint (see TintPressed, TintDisabled, TintFocused, TintNormal). |
property Image: TCastleImagePersistent read FImage; |
|
Optional image displayed on the button. |
property ImageScale: Single read FImageScale write SetImageScale default 1.0; |
|
Scaling of Image. |
property CustomBackgroundPressed: TCastleImagePersistent read FCustomBackgroundPressed; |
|
Background image on the pressed button. See CustomBackground for details. |
property CustomBackgroundDisabled: TCastleImagePersistent read FCustomBackgroundDisabled; |
|
Background image on the disabled button. See CustomBackground for details. |
property CustomBackgroundFocused: TCastleImagePersistent read FCustomBackgroundFocused; |
|
Background image on the focused button. See CustomBackground for details. |
property CustomBackgroundNormal: TCastleImagePersistent read FCustomBackgroundNormal; |
|
Background image on the normal button. See CustomBackground for details. |
property CustomTextColorUse: boolean read FCustomTextColorUse write FCustomTextColorUse default false; |
|
Should we use custom text color in CustomTextColor instead of |
property PaddingHorizontal: Single
read FPaddingHorizontal write SetPaddingHorizontal default DefaultPaddingHorizontal; |
|
Horizontal distance between text or Image and the button border. |
property PaddingVertical: Single
read FPaddingVertical write SetPaddingVertical default DefaultPaddingVertical; |
|
Vertical distance between text or Image and the button border. |
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). |
property AutoSizeWidth: boolean read FAutoSizeWidth write SetAutoSizeWidth default true; |
|
property AutoSizeHeight: boolean read FAutoSizeHeight write SetAutoSizeHeight default true; |
|
property MinHeight: Single read FMinHeight write SetMinHeight default 0; |
|
property OnClick: TNotifyEvent read FOnClick write FOnClick; |
|
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). |
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. |
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 |
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. |
property ImageLayout: TCastleButtonImageLayout
read FImageLayout write SetImageLayout default ilLeft; |
|
Where the Image is drawn on a button. |
property ImageMargin: Single read FImageMargin write SetImageMargin
default DefaultImageMargin; |
|
property Enabled: boolean read FEnabled write SetEnabled default true; |
|
Enabled button can be focused and clicked, is not grayed-out. |
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 |
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
|
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
|
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
|
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
|
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
|
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
|
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 also |
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 also |
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 also |
Generated by PasDoc 0.16.0.