Which User Control is the Closest Analog?
I'm reaching out to see if anyone might have advice.
Previously, I found great success using a UWP ListView to enable selection of one item in a series. I am not referring to selection mode, but the idea that an end user is able to navigate up and down through a list using keys (or a gamepad) without firing a selection changed event. This is made possible in UWP because focus (i.e. by pressing down on the keyboard or gamepad) does not result in a selection event firing. The end user must then press enter, spacebar, or gamepad 'A' to toggle or fire selection. Based on an understanding of this concept -- which Noesis GUI control would get me closest? Should I try ListBox or ListView?
Previously, I found great success using a UWP ListView to enable selection of one item in a series. I am not referring to selection mode, but the idea that an end user is able to navigate up and down through a list using keys (or a gamepad) without firing a selection changed event. This is made possible in UWP because focus (i.e. by pressing down on the keyboard or gamepad) does not result in a selection event firing. The end user must then press enter, spacebar, or gamepad 'A' to toggle or fire selection. Based on an understanding of this concept -- which Noesis GUI control would get me closest? Should I try ListBox or ListView?
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: Which User Control is the Closest Analog?
Unfortunately moving arrow keys in a ListBox/ListView do select the focused item.
Maybe you can play with an ItemsControl that contains Focusable controls as items, and manage selected item in the bound viewmodel using a command triggered when user hits space/enter/gamepad_A.
Could you please give a try and let us know if worked?
Maybe you can play with an ItemsControl that contains Focusable controls as items, and manage selected item in the bound viewmodel using a command triggered when user hits space/enter/gamepad_A.
Could you please give a try and let us know if worked?
Re: Which User Control is the Closest Analog?
Yes, I'll give it a shot.
Re: Which User Control is the Closest Analog?
I'm finding success by ignoring selection events and then looking at the UserControl.KeyDown event. One thing that I notice is that I get KeyDown.Space instead of KeyDown.GamepadAccept when I press the 'A' button on an XB1 controller. It seems like I am doing something wrong although I did use the Unity 'accept' input mapping shown in the documentation. Do you know if there is a Unity sample that shows a UI that has functional input mappings, i.e. the A button selects a given menu item?
Re: Which User Control is the Closest Analog?
OK, this is working for me quite well. I just needed to wrap my head around a few different ways of doing things. No blockers -- clear sailing from here out, I think. Thank you for the help!
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: Which User Control is the Closest Analog?
Nothing wrong on your side, we map gamepad buttons to regular keys to share controls implementation with default keyboard.I'm finding success by ignoring selection events and then looking at the UserControl.KeyDown event. One thing that I notice is that I get KeyDown.Space instead of KeyDown.GamepadAccept when I press the 'A' button on an XB1 controller. It seems like I am doing something wrong although I did use the Unity 'accept' input mapping shown in the documentation. Do you know if there is a Unity sample that shows a UI that has functional input mappings, i.e. the A button selects a given menu item?
You can still acccess original key though from event args:
Code: Select all
private void OnKeyDown(object sender, const KeyEventArgs e)
{
if (e.OriginalKey == Key.GamepadAccept) { ... }
}
Code: Select all
GamepadLeft -> Left
GamepadUp -> Up
GamepadRight -> Right
GamepadDown -> Down
GamepadAccept -> Space
GamepadCancel -> Escape
GamepadPageUp -> PageUp
GamepadPageDown -> PageDown
GamepadPageLeft -> PageLeft
GamepadPageRight -> PageRight
Re: Which User Control is the Closest Analog?
Thank you so much, this is very helpful to know. I didn't realize the original key had it -- perfect. I'm in really good shape. This is truly a great product.
Re: Which User Control is the Closest Analog?
Just an important detail, there is more than a simple mapping from gamepad to keyboard. Gamepad activates focus engagement. So for example, to edit a slider with the pad you need to hit 'A' button. With the keyboard that's not necessary as you have TAB to move the focus.
Re: Which User Control is the Closest Analog?
Thanks, jsantos! I encountered this behavior and I didn't know what it was. Thank you for anticipating and helping!Just an important detail, there is more than a simple mapping from gamepad to keyboard. Gamepad activates focus engagement. So for example, to edit a slider with the pad you need to hit 'A' button. With the keyboard that's not necessary as you have TAB to move the focus.
Re: Which User Control is the Closest Analog?
All our samples in C++ and C# work by default with gamepad. We don't have that in Unity because its input system is quite primitive and you need to store the input mapping at project level, so that cannot be done in the package we are distributing. We could do that in Github, as a separate project. We should definitely do that.Do you know if there is a Unity sample that shows a UI that has functional input mappings, i.e. the A button selects a given menu item?
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot], Semrush [Bot] and 8 guests