diff --git a/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs b/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs index b9ee25736..74edc67dc 100644 --- a/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs +++ b/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs @@ -27,6 +27,7 @@ using ShareX.ScreenCaptureLib.Properties; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; @@ -186,7 +187,8 @@ public bool NodesVisible private ToolStripSeparator tssObjectOptions, tssShapeOptions; private ToolStripMenuItem tsmiDeleteSelected, tsmiDeleteAll, tsmiBorderColor, tsmiFillColor, tsmiHighlightColor, tsmiQuickCrop; private ToolStripLabeledNumericUpDown tslnudBorderSize, tslnudCornerRadius, tslnudBlurRadius, tslnudPixelateSize; - private bool isLeftPressed, isRightPressed, isUpPressed, isDownPressed; + private bool isLeftPressed, isRightPressed, isUpPressed, isDownPressed, allowOptionsMenu; + private Stopwatch cmsCloseTimer; public ShapeManager(RegionCaptureForm form) { @@ -255,6 +257,14 @@ private void CreateContextMenu() } }; + cmsContextMenu.Closed += (sender, e) => + { + if (e.CloseReason == ToolStripDropDownCloseReason.AppClicked) + { + cmsCloseTimer = Stopwatch.StartNew(); + } + }; + #region Editor mode if (form.Mode == RegionCaptureMode.Editor) @@ -914,6 +924,8 @@ private void form_LostFocus(object sender, EventArgs e) private void form_MouseDown(object sender, MouseEventArgs e) { + allowOptionsMenu = cmsCloseTimer == null || cmsCloseTimer.ElapsedMilliseconds > 100; + if (e.Button == MouseButtons.Left) { if (!IsCreating) @@ -1245,7 +1257,10 @@ private void RunAction(RegionCaptureAction action) DeleteIntersectShape(); break; case RegionCaptureAction.OpenOptionsMenu: - OpenOptionsMenu(); + if (allowOptionsMenu) + { + OpenOptionsMenu(); + } break; case RegionCaptureAction.SwapToolType: SwapShapeType();