Class TCastleUserInterface
Unit
Declaration
type TCastleUserInterface = class(TCastleComponent)
Description
Basic user-interface class. All UI controls derive from this class, overriding chosen methods to react to some events.
Every control can have children controls, see Controls and ControlsCount. Parent control is recorded inside the Parent. A control may only be a child of one other control — that is, you cannot insert to the UI hierarchy the same control multiple times.
Control may handle mouse/keyboard input, see Press and Release methods.
Various methods return Boolean signalling if the input event is "handled". Input events that are handled are not passed to subsequent controls. This way we avoid 2 controls from reacting to the same mouse click, key press etc. Return True if something was done as a result of given input.
Every control also has a position and size and takes some rectangular space on the container.
The position is controlled using a Translation that works relative to the currently set anchors. You can change the position, adjusting also anchor, using an utility method Anchor: one overloaded version of Anchor changes the horizontal position and anchors (HorizontalAnchorSelf, HorizontalAnchorParent, Translation), the other overloaded version changes vertical position and anchors (VerticalAnchorSelf, VerticalAnchorParent, Translation). You can also change each individual property mentioned above.
The size is controlled using the Width, WidthFraction, Height, HeightFraction, FullSize, or AutoSizeToChildren properties.
The size (before UI scaling is applied) can be queried using EffectiveWidth and EffectiveHeight methods. The rectangle where the control is visible (during rendering, after applying UI scaling) can be queried using RenderRect and RenderRectWithBorder methods.
Note that some descendants perform auto-sizing, that is: their effective size follows some natural property of the control. For example, TCastleLabel size by default follows the TCastleLabel.Caption value, and ignores the explicit size set in Width and Height. You can turn off auto-sizing by TCastleLabel.AutoSize, to manually control the size using Width and Height.
All the coordinates passed here should follow the Castle Game Engine convention that (0, 0) is left-bottom window corner.
Source: ui/castleuicontrols_userinterface.inc (line 68).
Hierarchy
- TObject
- TPersistent
- TComponent
- TCastleComponent
- TCastleUserInterface
Generated by PasDoc 0.17.0.snapshot.