Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/modules/colorPicker/ColorPickerUI/Helpers/AppStateHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ internal void RegisterWindowHandle(System.Windows.Interop.HwndSource hwndSource)

public bool HandleEnterPressed()
{
if (!IsColorPickerVisible())
if (!_colorPickerShown)
{
return false;
}
Expand All @@ -241,14 +241,13 @@ public bool HandleEnterPressed()

public bool HandleEscPressed()
{
if (!BlockEscapeKeyClosingColorPickerEditor)
if (!BlockEscapeKeyClosingColorPickerEditor
&& (_colorPickerShown || (_colorEditorWindow != null && _colorEditorWindow.IsActive)))
{
return EndUserSession();
}
else
{
return false;
}

return false;
}

internal void MoveCursor(int xOffset, int yOffset)
Expand Down
13 changes: 3 additions & 10 deletions src/modules/colorPicker/ColorPickerUI/Keyboard/KeyboardMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,10 @@ private void Hook_KeyboardPressed(object sender, GlobalKeyboardHookEventArgs e)
var virtualCode = e.KeyboardData.VirtualCode;

// ESC pressed
if (virtualCode == KeyInterop.VirtualKeyFromKey(Key.Escape)
&& e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown
)
if (virtualCode == KeyInterop.VirtualKeyFromKey(Key.Escape) && e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown)
{
if (_appStateHandler.IsColorPickerVisible()
|| !AppStateHandler.BlockEscapeKeyClosingColorPickerEditor
)
{
e.Handled = _appStateHandler.EndUserSession();
return;
}
e.Handled = _appStateHandler.HandleEscPressed();
return;
}

if ((virtualCode == KeyInterop.VirtualKeyFromKey(Key.Space) || virtualCode == KeyInterop.VirtualKeyFromKey(Key.Enter)) && (e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown))
Expand Down
Loading