wckdspn
Topic Author
Posts: 67
Joined: 18 Aug 2012, 23:14

Keyboard focus

03 Aug 2014, 07:38

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?
 
User avatar
sfernandez
Site Admin
Posts: 1915
Joined: 22 Dec 2011, 19:20

Re: Keyboard focus

04 Aug 2014, 17:27

Hi, isn't it enough to check IsKeyboardFocused or IsKeyboardFocusedWithin on the desired elements?
Maybe I don't completely understand your scenario.
 
wckdspn
Topic Author
Posts: 67
Joined: 18 Aug 2012, 23:14

Re: Keyboard focus

04 Aug 2014, 18:49

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

Who is online

Users browsing this forum: jsantos and 1 guest