/// <summary> /// Called when a key is pressed, including mouse buttons. Returns true if this control consumed the event, otherwise false. /// </summary> /// <param name="E"></param> /// <returns></returns> public virtual bool OnKey(OnKeyEventArgs E) { if (E.Consumed) { return(false); } foreach (var C in Children) { C.OnKey(E); if (E.Consumed) { return(false); } } if (E.Key == Key.MouseLeft) { if (IsInside(E.MousePos)) { if (E.Pressed) { WasMousePressedDown = true; } else if (WasMousePressedDown) { WasMousePressedDown = false; OnMouseClick(E); } } else { WasMousePressedDown = false; } } return(false); }
public override void OnMouseClick(OnKeyEventArgs E) { Checked = !Checked; OnToggled?.Invoke(this, new OnCheckBoxToggledEventArgs(GUI, Checked)); }
/// <summary> /// Called when a pressed key is being released from the control. /// Mouse does not have to be inside of the control for this event to occur /// </summary> /// <param name="E"></param> public virtual void OnEndHold(OnKeyEventArgs E) { }
/// <summary> /// Called when a mouse key is being pressed on the control /// </summary> /// <param name="E"></param> public virtual void OnBeginHold(OnKeyEventArgs E) { }
/// <summary> /// Called when mouse is pressed and then released inside of the control. Pressed is always false here. /// </summary> /// <param name="E"></param> public virtual void OnMouseClick(OnKeyEventArgs E) { }