If region capture context menu closed because of right click then don't show context menu on mouse up, that way user can close context menu with right click

This commit is contained in:
Jaex 2016-09-09 21:14:37 +03:00
parent 76d4f85f5f
commit 837db296b5

View file

@ -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();