steveh
Topic Author
Posts: 25
Joined: 07 Oct 2019, 12:50

Two separate focused elements

08 Oct 2019, 13:27

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

Re: Two separate focused elements

09 Oct 2019, 12:15

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?
 
steveh
Topic Author
Posts: 25
Joined: 07 Oct 2019, 12:50

Re: Two separate focused elements

09 Oct 2019, 13:50

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

Re: Two separate focused elements

10 Oct 2019, 10:10

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?
 
steveh
Topic Author
Posts: 25
Joined: 07 Oct 2019, 12:50

Re: Two separate focused elements

10 Oct 2019, 11:27

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
 
User avatar
jsantos
Site Admin
Posts: 2903
Joined: 20 Jan 2012, 17:18
Contact:

Re: Two separate focused elements

14 Oct 2019, 08:02

I am going to mark this as solved but please do not hesitate to extend the thread with more questions. Thanks!

Who is online

Users browsing this forum: Google [Bot] and 2 guests