This project is read-only.

User Interface Input Control Set Focus

Sep 11, 2011 at 7:28 PM

I'd like to support Tabbing from one input control to the next.  Is there any way to set the Focus of an Input Control?

 

Thanks.

Sep 13, 2011 at 4:08 PM

There's a property "FocusedControl" as part of the Screen class that you can assign to switch focus. Directional focus switching via the cursor keys is already supported (it looks for the closest control in a 90° arc of the direction that has been selected). Tab and Shift+Tab are not implemented yet (search for "TODO: Implement focus switching" in Screen.cs), but aren't difficult to add since all you have to do is call the control in question's BringToFront() method.

The only drawback is that windows aren't really handled at all by the current focus switching system (there's no Alt+Tab or Ctrl+Tab to switch between windows) because the game I'm using this in avoids complex UI stuff so I can avoid having to code two different game UIs for Windows and the Xbox 360.

Sep 15, 2011 at 1:00 AM

This worked perfectly for me.  I have an inherited inputcontrol class and added a tab delegate to move from one to the next.  I am using input controls for numbers with a paired slider and value changes update game objects in real-time.  The framework works very well and is very easy to use.  Thanks.