Class TCastleView
Unit
Declaration
type TCastleView = class(TCastleUserInterface)
Description
"View" represents the current state of your application user interface. See also https://castle-engine.io/views for an overview of using TCastleView.
In a given container (like a window), in the simple case only one TCastleView is current at a given time, and it can be get or set using the TCastleContainer.View property. In more complex cases, you can use TCastleContainer.PushView and TCastleContainer.PopView to build a stack of views, and in effect multiple views are active at the same time. All of the views on stack are started, but only the top-most is resumed.
Each TCastleView has Start and Stop methods that you can override to perform work when view becomes part of the current view stack, or stops being part of it.
You can also override Resume and Pause methods, to perform work when the view becomes the top-most view or is no longer the top-most view. The distinction becomes important once you play around with pushing/popping view.
To define view user interface:
It is simplest to set
DesignUrlto the design file you created using CGE editor. Such user interface controls will be created right beforeStartand destroyed right afterStop(so the view UI always "resets" when view starts).You can always create more UI controls and add them to the view at any point. The view is a TCastleUserInterface descendant and you can add UI to it just by using
TCastleUserInterface.InsertFront.UI children can be added anytime you want, e.g. in
Startor in overridden constructor.UI children can be removed or destroyed anytime you want as well. You can use
FreeAtStopas an owner for anything you want to be automatically destroyed atStop.
Current view is placed on the list of container controls. This way view is notified about UI events, and can react to them. Note that our children will handle events before the view itself is notified about them, following TCastleUserInterface events behavior. This way view can:
React to
TCastleUserInterface.Press,TCastleUserInterface.Releaseof keys or mouse buttons,do something continuos in
TCastleUserInterface.Update.
See the TCastleUserInterface class for a lot of useful methods that you can override in your view descendants to capture various events.
Source: ui/castleuicontrols_view.inc (line 76).
Hierarchy
- TObject
- TPersistent
- TComponent
- TCastleComponent
- TCastleUserInterface
- TCastleView
Generated by PasDoc 0.17.0.snapshot.