From 9d39952670bdd6a86925ee0a515752d6ae46ed06 Mon Sep 17 00:00:00 2001 From: Seraphima Zykova Date: Mon, 30 Nov 2020 20:42:47 +0300 Subject: [PATCH] handle key events (#8281) --- .../editor/FancyZonesEditor/App.xaml.cs | 16 ++++++++++++++++ .../FancyZonesEditor/GridEditorWindow.xaml.cs | 3 +++ .../editor/FancyZonesEditor/Models/Monitor.cs | 4 ++++ 3 files changed, 23 insertions(+) diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/App.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/App.xaml.cs index 6ee98f3b18..e1f07e19a0 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/App.xaml.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/App.xaml.cs @@ -91,6 +91,22 @@ namespace FancyZonesEditor Overlay.Show(); } + public void App_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) + { + if (e.Key == System.Windows.Input.Key.LeftShift || e.Key == System.Windows.Input.Key.RightShift) + { + MainWindowSettings.IsShiftKeyPressed = false; + } + } + + public void App_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) + { + if (e.Key == System.Windows.Input.Key.LeftShift || e.Key == System.Windows.Input.Key.RightShift) + { + MainWindowSettings.IsShiftKeyPressed = true; + } + } + public static void ShowExceptionMessageBox(string message, Exception exception = null) { string fullMessage = FancyZonesEditor.Properties.Resources.Error_Report + PowerToysIssuesURL + " \n" + message; diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/GridEditorWindow.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/GridEditorWindow.xaml.cs index 417bbc61cc..a8fb06e154 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/GridEditorWindow.xaml.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/GridEditorWindow.xaml.cs @@ -19,6 +19,7 @@ namespace FancyZonesEditor InitializeComponent(); KeyUp += GridEditorWindow_KeyUp; + KeyDown += ((App)Application.Current).App_KeyDown; _stashedModel = (GridLayoutModel)(App.Overlay.CurrentDataContext as GridLayoutModel).Clone(); } @@ -36,6 +37,8 @@ namespace FancyZonesEditor { OnCancel(sender, null); } + + ((App)Application.Current).App_KeyUp(sender, e); } private GridLayoutModel _stashedModel; diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/Models/Monitor.cs b/src/modules/fancyzones/editor/FancyZonesEditor/Models/Monitor.cs index 3dd584aae0..4290d6b1d5 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/Models/Monitor.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/Models/Monitor.cs @@ -5,6 +5,7 @@ using System; using System.Reflection; using System.Windows; +using System.Windows.Input; using System.Windows.Media; using FancyZonesEditor.Utils; @@ -32,6 +33,9 @@ namespace FancyZonesEditor.Models Window.Background = (Brush)properties[milliseconds % properties.Length].GetValue(null, null); } + Window.KeyUp += ((App)Application.Current).App_KeyUp; + Window.KeyDown += ((App)Application.Current).App_KeyDown; + Window.Left = workArea.X; Window.Top = workArea.Y; Window.Width = workArea.Width;