Open task menu automatically

This commit is contained in:
Jaex 2022-08-19 20:10:13 +03:00
parent 244883d2f8
commit e2b93615fd
4 changed files with 27 additions and 9 deletions

View file

@ -37,24 +37,36 @@ public class MenuButton : Button
[DefaultValue(false)]
public bool ShowMenuUnderCursor { get; set; }
public void OpenMenu()
{
if (Menu != null)
{
OpenMenu(new Point(0, Height));
}
}
public void OpenMenu(Point menuPosition)
{
if (Menu != null)
{
Menu.Show(this, menuPosition);
}
}
protected override void OnMouseDown(MouseEventArgs mevent)
{
base.OnMouseDown(mevent);
if (Menu != null && mevent.Button == MouseButtons.Left)
{
Point menuLocation;
if (ShowMenuUnderCursor)
{
menuLocation = mevent.Location;
OpenMenu(mevent.Location);
}
else
{
menuLocation = new Point(0, Height - 1);
OpenMenu();
}
Menu.Show(this, menuLocation);
}
}

View file

@ -644,6 +644,9 @@ private void form_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyData)
{
case Keys.M:
CurrentTool = ShapeType.ToolSelect;
break;
case Keys.R:
case Keys.NumPad1:
CurrentTool = ShapeType.DrawingRectangle;
@ -710,9 +713,6 @@ private void form_KeyDown(object sender, KeyEventArgs e)
case Keys.PageDown:
MoveCurrentShapeDown();
break;
case Keys.M:
CurrentTool = ShapeType.ToolSelect;
break;
}
}

View file

@ -219,6 +219,11 @@ private void StopEditing()
UpdateHotkeyStatus();
}
public void OpenTaskMenu()
{
btnTask.OpenMenu();
}
private void SelectControl()
{
Selected = true;

View file

@ -188,6 +188,7 @@ private void btnAdd_Click(object sender, EventArgs e)
UpdateCheckStates();
control.Focus();
Update();
control.OpenTaskMenu();
}
private void btnRemove_Click(object sender, EventArgs e)