Skip to content

Commit

Permalink
Merge pull request #578 from babackman/master
Browse files Browse the repository at this point in the history
Allow KeyTrigger to match Alt+Key combinations
  • Loading branch information
nigel-sampson authored Jan 20, 2019
2 parents 38e1434 + 5f3641e commit f435e3c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions samples/scenarios/Scenario.KeyBinding/Input/KeyTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ protected override void OnDetaching()

private void OnAssociatedObjectKeyDown(object sender, KeyEventArgs e)
{
if ((e.Key == Key) && (Keyboard.Modifiers == GetActualModifiers(e.Key, Modifiers)))
var key = (e.Key == Key.System) ? e.SystemKey : e.Key;
if ((key == Key) && (Keyboard.Modifiers == GetActualModifiers(e.Key, Modifiers)))
{
InvokeActions(e);
}
Expand Down Expand Up @@ -70,4 +71,4 @@ static ModifierKeys GetActualModifiers(Key key, ModifierKeys modifiers)
return modifiers;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,10 @@ public void CtrlEnterPressed()
{
EnterMessage = "Ctrl+Enter has been pressed";
}

public void AltEnterPressed()
{
EnterMessage = "Alt+Enter has been pressed";
}
}
}
2 changes: 1 addition & 1 deletion samples/scenarios/Scenario.KeyBinding/Views/ShellView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<TextBlock />
<TextBox HorizontalAlignment="Left"
Width="278"
cal:Message.Attach="[Key Enter] = [EnterPressed]; [Gesture Ctrl+Enter] = [CtrlEnterPressed]">
cal:Message.Attach="[Key Enter] = [EnterPressed]; [Gesture Ctrl+Enter] = [CtrlEnterPressed]; [Gesture Alt+Enter] = [AltEnterPressed]">
</TextBox>
<TextBlock />
<TextBlock x:Name="EnterMessage"
Expand Down

0 comments on commit f435e3c

Please sign in to comment.