mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 04:07:40 +02:00
[Color Picker] Use escape key to exit colour editor UI (#10325)
* Use escape key to exit color editor UI * Logic handling formatting
This commit is contained in:
@@ -71,6 +71,25 @@ namespace ColorPicker.Helpers
|
|||||||
_colorEditorWindow.Show();
|
_colorEditorWindow.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void HideColorPickerEditor()
|
||||||
|
{
|
||||||
|
if (_colorEditorWindow != null)
|
||||||
|
{
|
||||||
|
_colorEditorWindow.Hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsColorPickerEditorVisible()
|
||||||
|
{
|
||||||
|
if (_colorEditorWindow != null)
|
||||||
|
{
|
||||||
|
// Check if we are visible and on top. Using focus producing unreliable results the first time the picker is opened.
|
||||||
|
return _colorEditorWindow.Topmost && _colorEditorWindow.IsVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static void SetTopMost()
|
public static void SetTopMost()
|
||||||
{
|
{
|
||||||
Application.Current.MainWindow.Topmost = false;
|
Application.Current.MainWindow.Topmost = false;
|
||||||
|
|||||||
@@ -72,8 +72,16 @@ namespace ColorPicker.Keyboard
|
|||||||
// ESC pressed
|
// ESC pressed
|
||||||
if (virtualCode == KeyInterop.VirtualKeyFromKey(Key.Escape))
|
if (virtualCode == KeyInterop.VirtualKeyFromKey(Key.Escape))
|
||||||
{
|
{
|
||||||
_appStateHandler.HideColorPicker();
|
if (_appStateHandler.IsColorPickerEditorVisible())
|
||||||
PowerToysTelemetry.Log.WriteEvent(new ColorPickerCancelledEvent());
|
{
|
||||||
|
_appStateHandler.HideColorPickerEditor();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_appStateHandler.HideColorPicker();
|
||||||
|
PowerToysTelemetry.Log.WriteEvent(new ColorPickerCancelledEvent());
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user