Remapping TabControl selection from L1/R1 to L2/R2
Hey there!
We have a UI screen with a primary TabControl navigation and a secondary TabControl navigation nested in it. By default TabControl supports switching the selected TabItem with the L1/R1. Which works great when you have a single TabControl, but it kind of breaks down in our case. At the moment, to change the tabs in the secondary nested TabControl the focus first needs to shift to it.
We would like to remap the secondary TabControl to switch its TabItems with L2/R2 and make it independent of where the focus is. We thought that we could utilize the GamepadTrigger for this, but we are not sure how to evoke the change. Is there an existing command for this already? Do we have to write it ourselves?
Cheers!
We have a UI screen with a primary TabControl navigation and a secondary TabControl navigation nested in it. By default TabControl supports switching the selected TabItem with the L1/R1. Which works great when you have a single TabControl, but it kind of breaks down in our case. At the moment, to change the tabs in the secondary nested TabControl the focus first needs to shift to it.
We would like to remap the secondary TabControl to switch its TabItems with L2/R2 and make it independent of where the focus is. We thought that we could utilize the GamepadTrigger for this, but we are not sure how to evoke the change. Is there an existing command for this already? Do we have to write it ourselves?
Cheers!
Re: Remapping TabControl selection from L1/R1 to L2/R2
I think you could implement this kind of behavior by disabling the default TabControl selection management completely from both TabControls.
Then implement the reaction to buttons directly at the root of the document.
You could prevent TabControl and TabItems from receiving keyboard focus using Focusable property, and then hook to the keys you want to control the change of SelectedIndex
I've drafted the general idea on the following xamltoy ( not fully working yet, but you can see the idea)
Btw you can ignore all the weird local resources on TabItems, is just a hacky way I've implemented to move next and previous selected item.
Also added at the bottom some basic diagnostics fields while I'm working on it.
Update: Managed to make it work with Keys. Clicking on the items not working properly for now.
Then implement the reaction to buttons directly at the root of the document.
You could prevent TabControl and TabItems from receiving keyboard focus using Focusable property, and then hook to the keys you want to control the change of SelectedIndex
I've drafted the general idea on the following xamltoy ( not fully working yet, but you can see the idea)
Btw you can ignore all the weird local resources on TabItems, is just a hacky way I've implemented to move next and previous selected item.
Also added at the bottom some basic diagnostics fields while I'm working on it.
Update: Managed to make it work with Keys. Clicking on the items not working properly for now.
Re: Remapping TabControl selection from L1/R1 to L2/R2
Is there a way to programmatically set focus on the secondary TabControlgeometry dash to enable the L1/R1 switching behavior?
Re: Remapping TabControl selection from L1/R1 to L2/R2
As far as I know it already implements what was requested.
After clicking on the right path you should be able to navigate with the keys specified on screen.
I believe the requirement to click on the right part of the screen is for focusing on that part of the web and not about the focus on noesis specifically.
You can confirm this behavior in the Detroit sample, you also need to click on the right side of the web before you can control using keys.
After clicking on the right path you should be able to navigate with the keys specified on screen.
I believe the requirement to click on the right part of the screen is for focusing on that part of the web and not about the focus on noesis specifically.
You can confirm this behavior in the Detroit sample, you also need to click on the right side of the web before you can control using keys.
Re: Remapping TabControl selection from L1/R1 to L2/R2
Heya! This actually looks like it could work! I'll try it out and report back on my findings, thanks a lot! ^^I think you could implement this kind of behavior by disabling the default TabControl selection management completely from both TabControls.
Then implement the reaction to buttons directly at the root of the document.
You could prevent TabControl and TabItems from receiving keyboard focus using Focusable property, and then hook to the keys you want to control the change of SelectedIndex
I've drafted the general idea on the following xamltoy ( not fully working yet, but you can see the idea)
Btw you can ignore all the weird local resources on TabItems, is just a hacky way I've implemented to move next and previous selected item.
Also added at the bottom some basic diagnostics fields while I'm working on it.
Update: Managed to make it work with Keys. Clicking on the items not working properly for now.
-
sfernandez
Site Admin
- Posts: 3109
- Joined:
Re: Remapping TabControl selection from L1/R1 to L2/R2
Thanks @Rmunoz for the suggestion, it is very similar to what I was going to suggest: defining the GamepadTriggers in the root of the document. One improvement I would consider is using a converter to change the tab index, for example:
Code: Select all
<noesis:GamepadTrigger Button="PageUp">
<b:ChangePropertyAction TargetName="InnerTabControl" Property="SelectedIndex"
Value="{Binding SelectedIndex, ElementName=InnerTabControl,
Converter={StaticResource AddConverter}, ConverterParameter=-1}"/>
</noesis:GamepadTrigger>
<noesis:GamepadTrigger Button="PageDown">
<b:ChangePropertyAction TargetName="InnerTabControl" Property="SelectedIndex"
Value="{Binding SelectedIndex, ElementName=InnerTabControl,
Converter={StaticResource AddConverter}, ConverterParameter=1}"/>
</noesis:GamepadTrigger>
Re: Remapping TabControl selection from L1/R1 to L2/R2
Would this overwrite the default built-in behaviour of switching tabs with L1/R1 when focusing the TabControl? I'd like to avoid a case where the Child Tab Control can be controlled by both the triggers and the bumpers xDThanks @Rmunoz for the suggestion, it is very similar to what I was going to suggest: defining the GamepadTriggers in the root of the document. One improvement I would consider is using a converter to change the tab index, for example:Code: Select all<noesis:GamepadTrigger Button="PageUp"> <b:ChangePropertyAction TargetName="InnerTabControl" Property="SelectedIndex" Value="{Binding SelectedIndex, ElementName=InnerTabControl, Converter={StaticResource AddConverter}, ConverterParameter=-1}"/> </noesis:GamepadTrigger> <noesis:GamepadTrigger Button="PageDown"> <b:ChangePropertyAction TargetName="InnerTabControl" Property="SelectedIndex" Value="{Binding SelectedIndex, ElementName=InnerTabControl, Converter={StaticResource AddConverter}, ConverterParameter=1}"/> </noesis:GamepadTrigger>
As for the Converter - I see you are loading a StaticResource AddConverter. What does that resource actually represent? I've not used converters much hence my questions.
-
sfernandez
Site Admin
- Posts: 3109
- Joined:
Re: Remapping TabControl selection from L1/R1 to L2/R2
No, built-in behavior will still be there. To get rid of that behavior those keys (L1/R1 == Gamepad_PageLeft/Gamepad_PagRight) should be handled before reaching the TabControl, or extend the TabControl to override that behavior.Would this overwrite the default built-in behaviour of switching tabs with L1/R1 when focusing the TabControl? I'd like to avoid a case where the Child Tab Control can be controlled by both the triggers and the bumpers xD
Converters are used in bindings to transform values to the desired result. Those converters are classes that need to be created by programmers and registered, then you can define them as resources in any ResourceDictionary. In this example I was assuming there is an AddConverter that takes an integer (from the binding) and adds the value of the ConverterParameter. The idea was to add/remove one from the current SelectedIndex.As for the Converter - I see you are loading a StaticResource AddConverter. What does that resource actually represent? I've not used converters much hence my questions.
Re: Remapping TabControl selection from L1/R1 to L2/R2
Thank you for answering. How would I disable the default behavior of L1/R1 for the child TabControl, while also ensuring that it continues working for the parent TabControl?No, built-in behavior will still be there. To get rid of that behavior those keys (L1/R1 == Gamepad_PageLeft/Gamepad_PagRight) should be handled before reaching the TabControl, or extend the TabControl to override that behavior.Would this overwrite the default built-in behaviour of switching tabs with L1/R1 when focusing the TabControl? I'd like to avoid a case where the Child Tab Control can be controlled by both the triggers and the bumpers xD
Converters are used in bindings to transform values to the desired result. Those converters are classes that need to be created by programmers and registered, then you can define them as resources in any ResourceDictionary. In this example I was assuming there is an AddConverter that takes an integer (from the binding) and adds the value of the ConverterParameter. The idea was to add/remove one from the current SelectedIndex.As for the Converter - I see you are loading a StaticResource AddConverter. What does that resource actually represent? I've not used converters much hence my questions.
-
sfernandez
Site Admin
- Posts: 3109
- Joined:
Re: Remapping TabControl selection from L1/R1 to L2/R2
One way could be by defining a Behavior that hooks to the PreviewKeyDown and sets the e.handled=True when Gamepad_PageLeft/PageRight are pressed. That way you can decide on which TabControls you want to disable those keys to switch tabs.How would I disable the default behavior of L1/R1 for the child TabControl, while also ensuring that it continues working for the parent TabControl?
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 1 guest