- unvestigate
- Posts: 32
- Joined:
Problem with gamepad and control focus
Hi,
I have a very basic placeholder pause menu for the game I am developing. The layout code looks like this:
Previously, I had only the resume and exit buttons, ie. the load button did not exist. The gamepad input worked pretty well. I set the focus on the resume button when the pause menu appears and the user was able to move between the buttons with the gamepad D-pad. However, if the user pressed up when the focus was on the resume button the focus moved off the buttons completely. Perhaps it focused the textblock above them or something? This is my first issue, how to I restrict the focus to move only between the buttons when using gamepad input?
My second issue started occuring when I added the load button between the other two buttons. Now when I enter the pause menu the gamepad input will only move the focus between the resume and load buttons (+ the issue with moving up from the resume buttons is still there). However, the focus won't ever move down to the exit button. It can however be clicked with the mouse. How do I solve this?
Thanks!
I have a very basic placeholder pause menu for the game I am developing. The layout code looks like this:
Code: Select all
<Border Grid.Row="1" Grid.Column="1" Background="#FF474F54" BorderBrush="#FF2F3538" BorderThickness="2" CornerRadius="5">
<StackPanel Margin="5">
<TextBlock HorizontalAlignment="Center" Margin="0,0,0,8" FontSize="30" Text="{Binding UILanguage.Resources[TEXT_UI_PAUSED], FallbackValue='Paused'}"/>
<Button x:Name="ResumeButton" Margin="0,0,0,4" Command="{Binding PauseResume}" Content="{Binding UILanguage.Resources[TEXT_UI_RESUME], FallbackValue='Resume'}"/>
<Button x:Name="LoadButton" Margin="0,0,0,4" Command="{Binding PauseLoadGame}" Content="{Binding UILanguage.Resources[TEXT_UI_LOAD_GAME], FallbackValue='Load game'}"/>
<Button x:Name="ExitButton" Command="{Binding PauseExit}" Content="{Binding UILanguage.Resources[TEXT_UI_EXIT], FallbackValue='Exit'}"/>
</StackPanel>
</Border>
My second issue started occuring when I added the load button between the other two buttons. Now when I enter the pause menu the gamepad input will only move the focus between the resume and load buttons (+ the issue with moving up from the resume buttons is still there). However, the focus won't ever move down to the exit button. It can however be clicked with the mouse. How do I solve this?
Thanks!
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: Problem with gamepad and control focus
You can restrict directional navigation in any panel by setting KeyboardNavigation.DirectionalNavigation property:
About the focus not moving down to the exit button this is something that can happen if there is other control under your pause dialog that is placed by chance between load and exit buttons, so when pressing down in your gamepad (or down arrow) it will move the focus to that control instead. But this is something you will also avoid by setting the directional navigation behavior in the panel wrapping the buttons, because then the focus will be moved locally within that panel.
Code: Select all
<StackPanel Margin="5" KeyboardNavigation.DirectionalNavigation="Cycle">
<TextBlock .../>
<Button x:Name="ResumeButton" .../>
<Button x:Name="LoadButton" .../>
<Button x:Name="ExitButton" .../>
</StackPanel>
- unvestigate
- Posts: 32
- Joined:
Re: Problem with gamepad and control focus
Awesome, that's exactly what I wanted. Thanks!
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: Problem with gamepad and control focus
Great, marking this as solved.
Who is online
Users browsing this forum: No registered users and 41 guests