2.3. 2D controls manager

A related topic is the 2D controls management. This is quite similar to the scene manager approach, except that now it's for 2D and some details are different.

Everything that has to receive window events must derive from TUIControl class. For example TCastleOnScreenMenu, and TCastleButton are all descendants of TUIControl. Even the TCastleSceneManager is TUIControl descendant, since scene manager by default acts as a viewport (2D rectangle) through which you can see your 3D world.

To actually use the TUIControl, you add it to the window's Controls list. If you use Lazarus component, then you're interested in TCastleControlCustom.Controls list. If you use our own window library, you're interested in the TCastleWindowCustom.Controls. Once control is added to the controls list, it will automatically receive all interesting events from our window.