Game Development Community

GUI Tutorials?

by Dan Rubenfield · in Torque X 2D · 04/16/2007 (2:47 am) · 1 replies

I can't get GUIBItmap items to receive focus. I'm at a complete loss.

I made a canvas. I made a new IGUIScreen that makes bitmaps controls.

These controls are extended slightly into a new control, but they're essentially guibitmaps.

Active is true, focusOnWake is true, awake is true, etc etc etc.

canfocus is ALWAYS false.

It's false on the base UI screen, as well as all subsequently added controls.


What do I need to do to make a UI control focusable?

#1
04/16/2007 (10:31 am)
There is some setup work that needs to be done for a control to be focusable:

1. The Style assigned to the Control must have the Focusable property set to true. This tells the Control and the Canvas that this control can respond to input events.

2. If you want the Control to take focus when it becomes awake, there is a property on the Control that needs to be set to true called FocusOnWake.


The CanFocus property is a get only property that will return true if the Style associated with it says the Control is focusable AND the control is visible AND the control is awake, and the control is active. If there is no Style it will return false.

You can test each of those yourself for debugging purpose, like so:
bool isFocusable = control.Style.Focusable;
bool isVisible = control.Visible;
bool isAwake = control.Awake;
bool isActive = control.Active;