IanM
Topic Author
Posts: 7
Joined: 14 Feb 2020, 07:10

Pressing gamepad B button on a Textbox

18 Jun 2020, 05:36

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.
<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>
Any ideas what I am missing?
 
User avatar
sfernandez
Site Admin
Posts: 1928
Joined: 22 Dec 2011, 19:20

Re: Pressing gamepad B button on a Textbox

19 Jun 2020, 16:36

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).
 
IanM
Topic Author
Posts: 7
Joined: 14 Feb 2020, 07:10

Re: Pressing gamepad B button on a Textbox

22 Jun 2020, 06:23

Setting SupportsFocusEngagement to false was what I wanted.
Thanks.
 
User avatar
sfernandez
Site Admin
Posts: 1928
Joined: 22 Dec 2011, 19:20

Re: Pressing gamepad B button on a Textbox

22 Jun 2020, 11:42

Great, thanks for the update.
 
IanM
Topic Author
Posts: 7
Joined: 14 Feb 2020, 07:10

Re: Pressing gamepad B button on a Textbox

23 Jun 2020, 02:10

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

Re: Pressing gamepad B button on a Textbox

23 Jun 2020, 11:55

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.
 
IanM
Topic Author
Posts: 7
Joined: 14 Feb 2020, 07:10

Re: Pressing gamepad B button on a Textbox

24 Jun 2020, 05:35

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

Re: Pressing gamepad B button on a Textbox

24 Jun 2020, 11:43

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: Bing [Bot] and 3 guests