Keyboard focus
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?
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?
-
sfernandez
Site Admin
- Posts: 3184
- Joined:
Re: Keyboard focus
Hi, isn't it enough to check IsKeyboardFocused or IsKeyboardFocusedWithin on the desired elements?
Maybe I don't completely understand your scenario.
Maybe I don't completely understand your scenario.
Re: Keyboard focus
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
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
Who is online
Users browsing this forum: Ahrefs [Bot], Semrush [Bot] and 3 guests