Page 1 of 1

Keyboard focus

Posted: 03 Aug 2014, 07:38
by wckdspn
What is the best way to handle keyboard focus in Unity?

So far it seems to restrict/allow focus, it seems the best method is to toggle the EnableKeyboard property on the panel. This seems to work fine.

However, we would also like to determine if a UIElement is currently acting on the focus it might have. A textbox for example, or a list box looking at arrow keys. We managed our own button bindings for most things, and would like to skip updating them if Noesis is handling input. The only method I've found is creating a dummy SoftwareKeyboardManager who receives OnShowKeyboard and OnHideKeyboard, but not only is it a terrible hack, it also doesn't get all focus events (just the owns requiring text input).

Any thoughts on whether or not there is something I missed?

Re: Keyboard focus

Posted: 04 Aug 2014, 17:27
by sfernandez
Hi, isn't it enough to check IsKeyboardFocused or IsKeyboardFocusedWithin on the desired elements?
Maybe I don't completely understand your scenario.

Re: Keyboard focus

Posted: 04 Aug 2014, 18:49
by wckdspn
IsKeyboardFocusWithin is what I wanted, yes. I knew about IsKeyboardFocused but in WPF I never had to check the whole tree.

Basically I just wanted a scheme in which I can check whether it would be better if where a user presses 'g' they were typing g into their text box, and not triggering something like self-destruct. Needed to contextualize :P