/// <summary> /// finds the children in which the cursor is inside and then call the MouseClick method for that child /// </summary> /// <param name="gHContainer"></param> /// <param name="customComponent"></param> /// <param name="e"></param> /// <param name="result"></param> public static void MouseClickChildren(this IGHPanel gHContainer, GH_Canvas sender, GHCustomComponent customComponent, GH_CanvasMouseEvent e, ref GHMouseEventResult result) { foreach (GHControl control in gHContainer.Items) { if (control.Enabled && control.Bounds.Contains(e.CanvasLocation)) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { control.MouseLeftClick(sender, customComponent, e, ref result); } else { control.MouseRightClick(sender, customComponent, e, ref result); } if (control is GHParameter && !((GHParameter)control).UpdateSolution) { result &= ~GHMouseEventResult.UpdateSolution; } if (result.HasFlag(GHMouseEventResult.Handled)) { return; } } } }
internal virtual void MouseOver(GH_Canvas sender, GHCustomComponent customComponent, GH_CanvasMouseEvent e, ref GHMouseEventResult result) { if (this is IGHPanel) { ((IGHPanel)this).MouseOverChildren(sender, customComponent, e, ref result); if (result.HasFlag(GHMouseEventResult.Invalidated | GHMouseEventResult.Handled)) { return; } } if (ActiveZone.Contains(e.CanvasLocation)) { if (!isMouseIn) { isMouseIn = true; result = result | GHMouseEventResult.Invalidated | GHMouseEventResult.Handled; return; } } else { if (isMouseIn) { isMouseIn = false; result = result | GHMouseEventResult.Invalidated | GHMouseEventResult.Handled; } } }
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)); }
internal virtual void MouseLeave(GH_Canvas sender, GHCustomComponent customComponent, GH_CanvasMouseEvent e, ref GHMouseEventResult result) { if (isMouseIn) { isMouseIn = false; result = result | GHMouseEventResult.Invalidated | GHMouseEventResult.Handled; return; } if (this is IGHPanel) { ((IGHPanel)this).MouseOverChildren(sender, customComponent, e, ref result); if (result.HasFlag(GHMouseEventResult.Invalidated | GHMouseEventResult.Handled)) { return; } } }
internal virtual void MouseKeyUp(GH_Canvas sender, GHCustomComponent customComponent, GH_CanvasMouseEvent e, ref GHMouseEventResult result) { if (this is IGHPanel) { IGHPanel panel = (IGHPanel)this; foreach (GHControl control in panel.Items) { if (control.Bounds.Contains(e.CanvasLocation)) { control.MouseKeyUp(sender, customComponent, e, ref result); if (result.HasFlag(GHMouseEventResult.Handled)) { return; } } } } }
/// <summary> /// finds the children in which the cursor is inside and then call the MouseOver method for that child /// </summary> /// <param name="gHContainer"></param> /// <param name="customComponent"></param> /// <param name="e"></param> /// <param name="result"></param> public static void MouseOverChildren(this IGHPanel gHContainer, GH_Canvas sender, GHCustomComponent customComponent, GH_CanvasMouseEvent e, ref GHMouseEventResult result) { foreach (GHControl control in gHContainer.Items) { if (control.Bounds.Contains(e.CanvasLocation) && control.Enabled) { control.MouseOver(sender, customComponent, e, ref result); if (result.HasFlag(GHMouseEventResult.Invalidated)) // no need to continue as this child already set the flag { return; } } else { control.MouseLeave(sender, customComponent, e, ref result); //if (result.HasFlag(GHMouseEventResult.Invalidated)) // no need to continue as this child already set the flag // return; } } }
internal override void MouseRightClick(GH_Canvas sender, GHCustomComponent customComponent, GH_CanvasMouseEvent e, ref GHMouseEventResult result) { base.MouseRightClick(sender, customComponent, e, ref result); if (result.HasFlag(GHMouseEventResult.Handled)) { return; } decimal d = Convert.ToDecimal(CurrentValue); NumericUpDownData <decimal> numeric = new NumericUpDownData <decimal>(d, Convert.ToDecimal(_min), Convert.ToDecimal(_max), FormatString); if (numeric.GetInput(PointToScreen(sender, Pos), out decimal val)) { CurrentValue = (float)val; result = result | GHMouseEventResult.UpdateSolution | GHMouseEventResult.Handled; } else { result = result | GHMouseEventResult.Handled; } showLabel = true; }
internal override void MouseRightClick(GH_Canvas sender, GHCustomComponent customComponent, GH_CanvasMouseEvent e, ref GHMouseEventResult result) { base.MouseRightClick(sender, customComponent, e, ref result); if (result.HasFlag(GHMouseEventResult.Handled)) { return; } int d = (int)CurrentValue; NumericUpDownData <int> numeric = new NumericUpDownData <int>(d, (int)_min, (int)_max, FormatString); if (numeric.GetInput(PointToScreen(sender, Pos), out int val)) { CurrentValue = val; result = result | GHMouseEventResult.UpdateSolution | GHMouseEventResult.Handled; } else { result = result | GHMouseEventResult.Handled; } showLabel = true; }
internal override void MouseRightClick(GH_Canvas sender, GHCustomComponent customComponent, GH_CanvasMouseEvent e, ref GHMouseEventResult result) { base.MouseRightClick(sender, customComponent, e, ref result); if (result.HasFlag(GHMouseEventResult.Handled)) { return; } double d = (double)CurrentValue; NumericUpDownData <double> numeric = new NumericUpDownData <double>(d, _min, _max, FormatString); //float s = GH_FontServer.MeasureString("A", SmallFont).Height * sender.Viewport.Zoom / 20; if (numeric.GetInput(PointToScreen(sender, Pos), out double val)) { CurrentValue = val; result = result | GHMouseEventResult.UpdateSolution | GHMouseEventResult.Handled; } else { result = result | GHMouseEventResult.Handled; } showLabel = true; }