public override GH_ObjectResponse RespondToMouseUp(GH_Canvas sender, GH_CanvasMouseEvent e) { GHCustomComponent owner = Owner as GHCustomComponent; GHMouseEventResult result = GHMouseEventResult.None; var backup = sender.Cursor; if (Bounds.Contains(e.CanvasLocation)) { foreach (GHControl item in owner.CustomControls.Values) { if (!item.Enabled) { continue; } if (item.Bounds.Contains(e.CanvasLocation)) { item.MouseKeyUp(sender, owner, e, ref result); if (item is GHParameter && !((GHParameter)item).UpdateSolution) { result &= ~GHMouseEventResult.UpdateSolution; } if (result.HasFlag(GHMouseEventResult.Handled)) { break; } } } if (result.HasFlag(GHMouseEventResult.Invalidated)) { sender.Invalidate(); } if (result.HasFlag(GHMouseEventResult.UpdateSolution)) { owner.ExpireSolution(true); } if (result.HasFlag(GHMouseEventResult.Handled)) { return(GH_ObjectResponse.Handled); } } return(base.RespondToMouseUp(sender, e)); }
public override GH_ObjectResponse RespondToMouseDown(GH_Canvas sender, GH_CanvasMouseEvent e) { GHCustomComponent owner = Owner as GHCustomComponent; if (Bounds.Contains(e.CanvasLocation)) { // click is inside the component // check which control is clicked GHMouseEventResult result = GHMouseEventResult.None; foreach (GHControl control in owner.CustomControls.Values) { if (control.Bounds.Contains(e.CanvasLocation)) { // click happened in this control if (e.Button == System.Windows.Forms.MouseButtons.Left) { control.MouseLeftClick(sender, owner, e, ref result); } else if (e.Button == System.Windows.Forms.MouseButtons.Right) { control.MouseRightClick(sender, owner, e, ref result); } if (control is GHParameter && !((GHParameter)control).UpdateSolution) { result &= ~GHMouseEventResult.UpdateSolution; } } } if (result.HasFlag(GHMouseEventResult.Invalidated)) { sender.Invalidate(); } if (result.HasFlag(GHMouseEventResult.UpdateSolution)) { owner.ExpireSolution(true); } if (result.HasFlag(GHMouseEventResult.Handled)) { return(GH_ObjectResponse.Handled); } } return(base.RespondToMouseDown(sender, e)); }