Page 1 of 1

Two separate focused elements

Posted: 08 Oct 2019, 13:27
by steveh
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

Re: Two separate focused elements

Posted: 09 Oct 2019, 12:15
by sfernandez
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

Posted: 09 Oct 2019, 13:50
by steveh
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.
Untitled-1.png
Untitled-1.png (9.8 KiB) Viewed 2456 times
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

Re: Two separate focused elements

Posted: 10 Oct 2019, 10:10
by sfernandez
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?

Re: Two separate focused elements

Posted: 10 Oct 2019, 11:27
by steveh
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

Re: Two separate focused elements

Posted: 14 Oct 2019, 08:02
by jsantos
I am going to mark this as solved but please do not hesitate to extend the thread with more questions. Thanks!