mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
[ColorPicker]Only close on escape if focused (#37895)
This commit is contained in:
@@ -222,7 +222,7 @@ namespace ColorPicker.Helpers
|
|||||||
|
|
||||||
public bool HandleEnterPressed()
|
public bool HandleEnterPressed()
|
||||||
{
|
{
|
||||||
if (!IsColorPickerVisible())
|
if (!_colorPickerShown)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -233,14 +233,13 @@ namespace ColorPicker.Helpers
|
|||||||
|
|
||||||
public bool HandleEscPressed()
|
public bool HandleEscPressed()
|
||||||
{
|
{
|
||||||
if (!BlockEscapeKeyClosingColorPickerEditor)
|
if (!BlockEscapeKeyClosingColorPickerEditor
|
||||||
|
&& (_colorPickerShown || (_colorEditorWindow != null && _colorEditorWindow.IsActive)))
|
||||||
{
|
{
|
||||||
return EndUserSession();
|
return EndUserSession();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void MoveCursor(int xOffset, int yOffset)
|
internal void MoveCursor(int xOffset, int yOffset)
|
||||||
|
|||||||
@@ -70,17 +70,10 @@ namespace ColorPicker.Keyboard
|
|||||||
var virtualCode = e.KeyboardData.VirtualCode;
|
var virtualCode = e.KeyboardData.VirtualCode;
|
||||||
|
|
||||||
// ESC pressed
|
// ESC pressed
|
||||||
if (virtualCode == KeyInterop.VirtualKeyFromKey(Key.Escape)
|
if (virtualCode == KeyInterop.VirtualKeyFromKey(Key.Escape) && e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown)
|
||||||
&& e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (_appStateHandler.IsColorPickerVisible()
|
e.Handled = _appStateHandler.HandleEscPressed();
|
||||||
|| !AppStateHandler.BlockEscapeKeyClosingColorPickerEditor
|
return;
|
||||||
)
|
|
||||||
{
|
|
||||||
e.Handled = _appStateHandler.EndUserSession();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((virtualCode == KeyInterop.VirtualKeyFromKey(Key.Space) || virtualCode == KeyInterop.VirtualKeyFromKey(Key.Enter)) && (e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown))
|
if ((virtualCode == KeyInterop.VirtualKeyFromKey(Key.Space) || virtualCode == KeyInterop.VirtualKeyFromKey(Key.Enter)) && (e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown))
|
||||||
|
|||||||
Reference in New Issue
Block a user