Two separate focused elements
Hi guys,
What is the suggested method of having 2 different users control focus on different parts of the screen. We have a lobby-style screen where 2 different users are controlling different elements. Currently I've implemented the input in our game with keyboard focus and the focus manager. Most of the input is handled automatically for us by the KeyboardNavigation class.
My current thinking is that I need to ignore the keyboard focus and instead just use the UIElement::IsFocused property. I would then need to implement my own function to navigate the buttons (essentially re-implement KeyboardNavigation and instance it for each controlling user). When a user changes focus, instead of setting the keyboard focus I only need to set the element itself to be focused. Does this sound reasonable? Is there a simpler solution? If not, that's fine, I just wanted to make sure I'm not missing something trivial.
Cheers,
-Steven
What is the suggested method of having 2 different users control focus on different parts of the screen. We have a lobby-style screen where 2 different users are controlling different elements. Currently I've implemented the input in our game with keyboard focus and the focus manager. Most of the input is handled automatically for us by the KeyboardNavigation class.
My current thinking is that I need to ignore the keyboard focus and instead just use the UIElement::IsFocused property. I would then need to implement my own function to navigate the buttons (essentially re-implement KeyboardNavigation and instance it for each controlling user). When a user changes focus, instead of setting the keyboard focus I only need to set the element itself to be focused. Does this sound reasonable? Is there a simpler solution? If not, that's fine, I just wanted to make sure I'm not missing something trivial.
Cheers,
-Steven
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: Two separate focused elements
Just to completely understand your scenario, is the screen split so each player can only move the focus on their own controls, or the focus of each player can be moved anywhere, even have both users focusing the same control?
Re: Two separate focused elements
Sorry, I should've been clearer. This screen is a lobby style screen. It is not split screen, however, multiple users are focusing different element.
In this case, user 0 can navigate between the options A, B and C elements on the left half of the screen. User 1 can navigate between options A, B and C elements on the right half of the screen. They can never both focus the same elements, but they are navigating at the same time on the same view.
-Steven
In this case, user 0 can navigate between the options A, B and C elements on the left half of the screen. User 1 can navigate between options A, B and C elements on the right half of the screen. They can never both focus the same elements, but they are navigating at the same time on the same view.
-Steven
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: Two separate focused elements
This is similar then to this other post: viewtopic.php?f=3&t=1807#p10275
Inside a single View it is not possible to have more than 1 element focused. Only one control can have the keyboard focus, and IsFocused property is updated by the Keyboard.
As I explained there, you should have one View for each player, to render their own part of the UI and to handle the input for that player.
Do you think this can work for you?
Inside a single View it is not possible to have more than 1 element focused. Only one control can have the keyboard focus, and IsFocused property is updated by the Keyboard.
As I explained there, you should have one View for each player, to render their own part of the UI and to handle the input for that player.
Do you think this can work for you?
Re: Two separate focused elements
Thank you for the response. Yeah, this would work for us I reckon. It may require a bit of refactoring but I'm sure I can make it work.
Cheers,
-Steven
Cheers,
-Steven
Re: Two separate focused elements
I am going to mark this as solved but please do not hesitate to extend the thread with more questions. Thanks!