[ColorPicker]Only close on escape if focused (#37895)

This commit is contained in:
PesBandi
2025-04-15 05:15:41 +02:00
committed by GitHub
parent 293fa262bb
commit 21aa49cefb
2 changed files with 8 additions and 16 deletions

View File

@@ -222,7 +222,7 @@ namespace ColorPicker.Helpers
public bool HandleEnterPressed()
{
if (!IsColorPickerVisible())
if (!_colorPickerShown)
{
return false;
}
@@ -233,14 +233,13 @@ namespace ColorPicker.Helpers
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)

View File

@@ -70,17 +70,10 @@ namespace ColorPicker.Keyboard
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))