Pressing gamepad B button on a Textbox
I'm having some trouble getting my BackCommand to execute when pressing the Gamepad B button on a Textbox.
Instead of calling my BackCommand it de-focuses the text entry and I have to press it a second time for it to work.
Pressing the escape key calls my BackCommand first time with no problems.
Any ideas what I am missing?
Instead of calling my BackCommand it de-focuses the text entry and I have to press it a second time for it to work.
Pressing the escape key calls my BackCommand first time with no problems.
Code: Select all
<TextBox x:Name="FirstNameTextbox" Text="{Binding PlayerFirstName}">
<i:Interaction.Triggers>
<noesis:GamepadTrigger FiredOn="ButtonDown" Button="Accept">
<i:InvokeCommandAction Command="{Binding CloseNamePopupCommand}" />
</noesis:GamepadTrigger>
</i:Interaction.Triggers>
<TextBox.InputBindings>
<KeyBinding Key="Esc" Command="{Binding BackCommand}"/>
<KeyBinding Key="Enter" Command="{Binding CloseNamePopupCommand}"/>
</TextBox.InputBindings>
</TextBox>
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: Pressing gamepad B button on a Textbox
The TextBox control has focus engagement enabled by default so when it gets focused, using the directional navigation doesn't get trapped trying to move the cursor through the text. Instead you have to press Accept (A) button to "engage" the focus and start writing/moving cursor around, and press Cancel (B) button to "disengage" the focus.
Is that what you are seeing?
If you don't want that behavior in your TextBox you can set IsFocusEngagementEnabled property to false (this is in 3.0, in previous 2.2 version the property name was SupportsFocusEngagement).
Is that what you are seeing?
If you don't want that behavior in your TextBox you can set IsFocusEngagementEnabled property to false (this is in 3.0, in previous 2.2 version the property name was SupportsFocusEngagement).
Re: Pressing gamepad B button on a Textbox
Setting SupportsFocusEngagement to false was what I wanted.
Thanks.
Thanks.
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: Pressing gamepad B button on a Textbox
Great, thanks for the update.
Re: Pressing gamepad B button on a Textbox
We have just realised that this solution does not fully work for us.
Setting SupportsFocusEngagement to false allow us to call our BackCommand with just one Cancel input, but when focussing the textbox again we can't input text.
So I assume that setting SupportsFocusEngagement to false has skipped some functionality that was required.
Setting SupportsFocusEngagement to false allow us to call our BackCommand with just one Cancel input, but when focussing the textbox again we can't input text.
So I assume that setting SupportsFocusEngagement to false has skipped some functionality that was required.
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: Pressing gamepad B button on a Textbox
This is a bug, TextBox should work fine with IsFocusEngagementEnabled="False". I reproduced the problem and we will fix it for the next release: #1732
Anyway, just to understand better your scenario, do you want to execute the BackCommand to close the screen where the TextBox is being edited?
Does the screen contain more TextBoxes or controls apart from "FirstNameTextbox"?
Because if you have more textboxes and disable the focus engagement, you won't be able to navigate through them using the gamepad.
Anyway, just to understand better your scenario, do you want to execute the BackCommand to close the screen where the TextBox is being edited?
Does the screen contain more TextBoxes or controls apart from "FirstNameTextbox"?
Because if you have more textboxes and disable the focus engagement, you won't be able to navigate through them using the gamepad.
Re: Pressing gamepad B button on a Textbox
The screen that I am working on contains two textboxes (first name and surname).
When the user chooses to change the first name we manually set focus (via c++ code) to the first name textbox when we display the textbox to the user.
Then when the user is done the back command will hide the textbox and manually return focus to the original UI element.
When the user chooses to change the first name we manually set focus (via c++ code) to the first name textbox when we display the textbox to the user.
Then when the user is done the back command will hide the textbox and manually return focus to the original UI element.
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: Pressing gamepad B button on a Textbox
Then it looks like disabling IsFocusEngagementEnabled on that TextBox is the correct approach, because you don't need to move focus to other control using the gamepad while editing the name. We fixed the bug #1732 for the next release so you can use it.
Who is online
Users browsing this forum: No registered users and 56 guests