protected override void OnMouseUp(MouseEventArgs e) { if (e.Button != MouseButtons.Right) { return; } var m = new AMenu(); m["Retry\tF3"] = o => { this.DialogResult = DialogResult.Retry; this.Close(); }; m["Cancel\tEsc"] = o => this.Close(); m.Show(this); }
void _ContextMenu() { if (_m._name == null) { return; } if (!CanGoToEdit_) { return; } var p = this.MouseClientXY(); var contextItem = this.GetItemAt(p); if (contextItem == null) //maybe p is at the left or rigt of a textbox, label etc { foreach (ToolStripItem v in this.Items) { var k = v.Bounds; if (p.y >= k.Y && p.y < k.Bottom) { contextItem = v; break; } } } #if true using var m = new Util.ClassicPopupMenu_(); m.Add(100, "Edit"); _cancelClosing = true; //in some cases .NET installs a message hook to catch clicks int r = m.Show(this.Hwnd()); _cancelClosing = false; switch (r) { case 100: _m.Close(); _m.GoToEdit_(contextItem); break; } #else //.NET does not like it. Tries to close the main menu, and if we cancel it, menu partially stops working. var m = new AMenu(); m["Edit"] = o => _m.GoToEdit_(contextItem); m.Control.RenderMode = ToolStripRenderMode.System; m.Show(this); #endif }