[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:
parent
612e9f8b99
commit
77d67f3599
|
@ -71,6 +71,25 @@ namespace ColorPicker.Helpers
|
|||
_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()
|
||||
{
|
||||
Application.Current.MainWindow.Topmost = false;
|
||||
|
|
|
@ -72,8 +72,16 @@ namespace ColorPicker.Keyboard
|
|||
// ESC pressed
|
||||
if (virtualCode == KeyInterop.VirtualKeyFromKey(Key.Escape))
|
||||
{
|
||||
_appStateHandler.HideColorPicker();
|
||||
PowerToysTelemetry.Log.WriteEvent(new ColorPickerCancelledEvent());
|
||||
if (_appStateHandler.IsColorPickerEditorVisible())
|
||||
{
|
||||
_appStateHandler.HideColorPickerEditor();
|
||||
}
|
||||
else
|
||||
{
|
||||
_appStateHandler.HideColorPicker();
|
||||
PowerToysTelemetry.Log.WriteEvent(new ColorPickerCancelledEvent());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue