mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-29 17:02:05 +13:00
fixed #7346: Improve CloseOnEscape logic
This commit is contained in:
parent
d64ae9702f
commit
1a308afdda
2 changed files with 7 additions and 2 deletions
|
@ -56,20 +56,24 @@ public static void ForceActivate(this Form form)
|
||||||
|
|
||||||
public static void CloseOnEscape(this Form form)
|
public static void CloseOnEscape(this Form form)
|
||||||
{
|
{
|
||||||
|
bool escapePressed = false;
|
||||||
|
|
||||||
form.KeyPreview = true;
|
form.KeyPreview = true;
|
||||||
|
|
||||||
form.KeyDown += (sender, e) =>
|
form.KeyDown += (sender, e) =>
|
||||||
{
|
{
|
||||||
if (e.KeyCode == Keys.Escape)
|
if (e.KeyCode == Keys.Escape)
|
||||||
{
|
{
|
||||||
|
escapePressed = true;
|
||||||
e.SuppressKeyPress = true;
|
e.SuppressKeyPress = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
form.KeyUp += (sender, e) =>
|
form.KeyUp += (sender, e) =>
|
||||||
{
|
{
|
||||||
if (e.KeyCode == Keys.Escape)
|
if (e.KeyCode == Keys.Escape && escapePressed)
|
||||||
{
|
{
|
||||||
|
escapePressed = false;
|
||||||
form.DialogResult = DialogResult.Cancel;
|
form.DialogResult = DialogResult.Cancel;
|
||||||
form.Close();
|
form.Close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -609,7 +609,8 @@ internal bool ShowExitConfirmation()
|
||||||
if (IsImageModified)
|
if (IsImageModified)
|
||||||
{
|
{
|
||||||
Pause();
|
Pause();
|
||||||
DialogResult dialogResult = MessageBox.Show(this, Resources.RegionCaptureForm_SaveChangesBeforeClosingEditor, Resources.RegionCaptureForm_ShowExitConfirmation_ShareXImageEditor,
|
DialogResult dialogResult = MessageBox.Show(this, Resources.RegionCaptureForm_SaveChangesBeforeClosingEditor,
|
||||||
|
Resources.RegionCaptureForm_ShowExitConfirmation_ShareXImageEditor,
|
||||||
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
|
MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
|
||||||
|
|
||||||
if (dialogResult == DialogResult.Yes)
|
if (dialogResult == DialogResult.Yes)
|
||||||
|
|
Loading…
Reference in a new issue