mirror of https://github.com/ShareX/ShareX.git
fixed #7346: Improve CloseOnEscape logic
This commit is contained in:
parent
d64ae9702f
commit
1a308afdda
|
@ -56,20 +56,24 @@ namespace ShareX.HelpersLib
|
|||
|
||||
public static void CloseOnEscape(this Form form)
|
||||
{
|
||||
bool escapePressed = false;
|
||||
|
||||
form.KeyPreview = true;
|
||||
|
||||
form.KeyDown += (sender, e) =>
|
||||
{
|
||||
if (e.KeyCode == Keys.Escape)
|
||||
{
|
||||
escapePressed = true;
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
};
|
||||
|
||||
form.KeyUp += (sender, e) =>
|
||||
{
|
||||
if (e.KeyCode == Keys.Escape)
|
||||
if (e.KeyCode == Keys.Escape && escapePressed)
|
||||
{
|
||||
escapePressed = false;
|
||||
form.DialogResult = DialogResult.Cancel;
|
||||
form.Close();
|
||||
}
|
||||
|
|
|
@ -609,7 +609,8 @@ namespace ShareX.ScreenCaptureLib
|
|||
if (IsImageModified)
|
||||
{
|
||||
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);
|
||||
|
||||
if (dialogResult == DialogResult.Yes)
|
||||
|
|
Loading…
Reference in New Issue