View Issue Details

IDProjectCategoryView StatusLast Update
0002436NoesisGUIC++ SDKpublic2022-11-18 10:09
Reportertsilmer Assigned Tosfernandez  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionno change required 
Product Version3.1.5 
Target Version3.1.6Fixed in Version3.1.6 
Summary0002436: GamepadTrigger does not work inside ContextMenu
DescriptionAny kind of Interaction.Triggers such as KeyTrigger, EventTrigger, etc work as expected when used inside a ContextMenu. But when a GamepadTrigger is used it does not trigger the actions.
Steps To ReproduceIn the following example, the action under KeyTrigger works as expected, while the GamepadTrigger is never executed (the same GamepadTrigger outside of the ContextMenu also works just fine):

<DataTemplate x:Key="TreeViewComponentStyle">
  <Border x:Name="OuterBorder">
    <Border.ContextMenu>
      <ContextMenu Name="MyContextMenu">
        <MenuItem Header="Test" />

         <b:Interaction.Triggers>
            <noesis:GamepadTrigger Button="Cancel" FiredOn="ButtonDown">
              <b:InvokeCommandAction Command="{Binding Path=DataContext.DebugPrint, ElementName=MainWindow}" CommandParameter="GAMEPAD_TRIGGER"/>
            </noesis:GamepadTrigger>

            <b:KeyTrigger Key="a">
              <b:InvokeCommandAction Command="{Binding Path=DataContext.DebugPrint, ElementName=MainWindow}" CommandParameter="KEY_TRIGGER"/>
            </b:KeyTrigger>
          </b:Interaction.Triggers>
      </ContextMenu>
    </Border.ContextMenu>
  </Border>
</DataTemplate>
TagsNo tags attached.
PlatformAny

Activities

sfernandez

sfernandez

2022-10-06 19:35

manager   ~0008089

By default (ActiveOnFocus="False") KeyTrigger and GamepadTrigger hook to the XAML root to listen for the KeyDown/Up event.
In this case what is happening with the KeyTrigger Key="A" is that no element in the event route is handling that key, so it reaches the root, and then the KeyTrigger can process the event and execute the actions.
But for GamepadTrigger Button="Cancel" the MenuItem that has the submenu opened, as it is part of the event route, it handles the key (Cancel == Escape) and closes the submenu, so when the event reaches the root it is already handled and the GamepadTrigger is not processed.

If you use another gamepad button (for example the "Menu" button) that is not handled by elements in the tree, then the GamepadTrigger works as expected.

But what you should do is to set ActiveOnFocus="True" so the GamepadTrigger is processed on the ContextMenu where you are defining it. That way the trigger can be processed and execute its actions before other elements in the tree.

<ContextMenu Name="MyContextMenu">
         <b:Interaction.Triggers>
            <noesis:GamepadTrigger Button="Cancel" FiredOn="ButtonDown" ActiveOnFocus="True">
              <b:InvokeCommandAction Command="{Binding Path=DataContext.DebugPrint, ElementName=MainWindow}" CommandParameter="GAMEPAD_TRIGGER"/>
            </noesis:GamepadTrigger>
         <b:Interaction.Triggers>
  ...
</ContextMenu>

Issue History

Date Modified Username Field Change
2022-10-04 01:21 tsilmer New Issue
2022-10-06 17:53 sfernandez Assigned To => sfernandez
2022-10-06 17:53 sfernandez Status new => assigned
2022-10-06 17:53 sfernandez Target Version => 3.1.6
2022-10-06 19:35 sfernandez Status assigned => feedback
2022-10-06 19:35 sfernandez Note Added: 0008089
2022-11-07 17:13 sfernandez Target Version 3.1.6 => 3.1.7
2022-11-07 17:17 sfernandez Target Version 3.1.7 => 3.1.6
2022-11-18 10:09 sfernandez Status feedback => resolved
2022-11-18 10:09 sfernandez Resolution open => no change required
2022-11-18 10:09 sfernandez Fixed in Version => 3.1.6