Skip to content

Commit

Permalink
Fix Alt+F4 hotkey mistakenly triggered from other windows
Browse files Browse the repository at this point in the history
  • Loading branch information
yfdyh000 committed Apr 8, 2022
1 parent 82d8f64 commit f717da3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion PhotoSift/frmMain_Input.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace PhotoSift
/// </summary>
public partial class frmMain : Form
{
private static bool isAltF4Down;

// -- Handle Menu Items -------------------------------------------------------------------------------------

Expand Down Expand Up @@ -746,7 +747,8 @@ private void frmMain_KeyUp( object sender, KeyEventArgs e )
}
#endif

if (e.Modifiers == (Keys.Alt) && e.KeyCode == Keys.F4) mnuExit_Click(sender, e); // Workaround for WMP control
if (e.Modifiers == (Keys.Alt) && e.KeyCode == Keys.F4 && isAltF4Down) mnuExit_Click(sender, e); // Workaround for WMP control
isAltF4Down = false;

// Control/Shift/Alt are not used below so skip the rest
if ( e.Alt || e.Control || e.Shift ) return;
Expand Down Expand Up @@ -957,6 +959,8 @@ private void frmMain_KeyDown( object sender, KeyEventArgs e )
e.Handled = true;
}

if (e.Modifiers == (Keys.Alt) && e.KeyCode == Keys.F4) isAltF4Down = true;

// keyboard zoom (handled in keydown event to allow for key repeats)
else if( e.KeyCode == Keys.Add || e.KeyCode == Keys.Subtract || e.KeyCode == Keys.Oemplus || e.KeyCode == Keys.OemMinus )
{
Expand Down

0 comments on commit f717da3

Please sign in to comment.