/// <summary> /// Updates button skin to reflect current mouse state. /// </summary> /// <param name="args">Mouse event arguments.</param> protected override void OnMouseUp(MouseEventArgs args) { if (args.Button == MouseButtons.Left) { // Check that the mouse was depressed inside the button if (CheckCoordinates(args.Position.X, args.Position.Y)) { this.isChecked = !this.isChecked; CurrentSkinState = SkinState.Hover; if (this.isChecked) CurrentSkinState = SkinState.CheckedHover; } else { CurrentSkinState = SkinState.Normal; if (this.isChecked) CurrentSkinState = SkinState.Checked; } } base.OnMouseUp(args); }
//------------------------------------------------------------------------- public override bool injectMouseMove(MouseEventArgs e) { _interfaceMgr.injectMouseMove(e.Position); return base.injectMouseMove(e); }
/// <summary> /// Updates button skin to reflect current mouse state. /// </summary> /// <param name="args">Mouse event arguments.</param> protected override void OnMouseOut(MouseEventArgs args) { base.OnMouseOut(args); CurrentSkinState = SkinState.Normal; if (this.isChecked) CurrentSkinState = SkinState.Checked; }
/// <summary> /// Add highlight. /// </summary> /// <param name="args">Mouse event arguments.</param> protected override void OnMouseOver(MouseEventArgs args) { base.OnMouseOver(args); AddHighlight(); }
/// <summary> /// If any menu is currently open, automatically open popups when the /// mouse hovers over the menu item. /// </summary> /// <param name="args">Mouse event arguments.</param> protected override void MouseMoveIntercept(MouseEventArgs args) { if (this.isPopUpShown && CheckCoordinates(args.Position.X, args.Position.Y)) { foreach (MenuItem item in this.menuItems) { if (item.CheckCoordinates(args.Position.X, args.Position.Y)) { if (item != this.selectedMenuItem) { if (this.selectedMenuItem != null) this.selectedMenuItem.ClosePopUp(); item.SelectByMove(); } break; } } } }
protected void OnButtonMouseOver(MouseEventArgs args) { if (!this.isListBoxOpen) this.button.CurrentSkinState = SkinState.Hover; }
/// <summary> /// Open popup menu if there is one. /// </summary> /// <param name="args"></param> protected override void OnMouseDown(MouseEventArgs args) { base.OnMouseDown(args); if (args.Button == MouseButtons.Left) Select(); }
/// <summary> /// Invokes MouseOut event. /// </summary> /// <param name="args">Event arguments.</param> internal void InvokeMouseOut(MouseEventArgs args) { this.isMouseOver = false; MouseOut.Invoke(args); }
/// <summary> /// Invokes MouseOver event. /// </summary> /// <param name="args">Event arguments.</param> internal void InvokeMouseOver(MouseEventArgs args) { this.isMouseOver = true; MouseOver.Invoke(args); }
/// <summary> /// Used for click event. Override to handle event. /// </summary> /// <param name="args">Mouse event arguments.</param> protected virtual void OnMouseUp(MouseEventArgs args) { if (this.isPressed) { if (args.Button == MouseButtons.Left) { this.isPressed = false; // Check if button was clicked if (CheckCoordinates(args.Position.X, args.Position.Y)) { if (Click != null) Click.Invoke(this); } } } }
/// <summary> /// Asks children for their mouse status, and invokes MouseOut event /// for this control if necessary. /// </summary> /// <param name="args">Mouse event arguments.</param> /// <returns>Control asking for MouseOver event, otherwise null.</returns> internal UIComponent CheckMouseStatus(MouseEventArgs args) { UIComponent result = null; // Check if control can receive MouseOver and MouseOut events if (this.Visible) { // Check if MouseOut event should be invoked bool mouseOver = CheckCoordinates(args.Position.X, args.Position.Y); if (this.isMouseOver) { if (!mouseOver) { this.isMouseOver = false; MouseOut.Invoke(args); } } if (mouseOver) { float zTemp = 0.0f; // Ask each child to check it's mouse status foreach (UIComponent control in this.controls) { // Keep track of highest z-order if (control.ZOrder >= zTemp) { UIComponent child = control.CheckMouseStatus(args); if (child != null) { // MouseOut last result if (result != null && result.IsMouseOver) result.InvokeMouseOut(args); // Set result and update highest z-order result = child; zTemp = control.ZOrder; } } } // If no child requires the event, see if this control can // take it. if (result == null && this.canHaveFocus) result = this; } else { // Ensure each control can receive MouseOut event foreach (UIComponent control in this.controls) control.CheckMouseStatus(args); } } return result; }
/// <summary> /// Does nothing, override to handle event. /// </summary> /// <param name="args">Mouse event arguments.</param> protected virtual void OnMouseOver(MouseEventArgs args) { }
/// <summary> /// Does nothing, override to handle event. /// </summary> /// <param name="args">Mouse event arguments.</param> protected virtual void OnMouseMove(MouseEventArgs args) { }
/// <summary> /// Check if mouse button was released on top of a menu item. /// </summary> /// <param name="args">Mouse event arguments.</param> protected override void MouseUpIntercept(MouseEventArgs args) { if (this.isPopUpShown && CheckCoordinates(args.Position.X, args.Position.Y)) { // Check if a child menu item should be clicked foreach (MenuItem item in this.menuItems) { if (item.CheckCoordinates(args.Position.X, args.Position.Y)) { item.InvokeClick(); break; } } } }
/// <summary> /// MouseMove input event handler function. /// </summary> /// <param name="e">MouseEvent arguments.</param> /// <returns>True if handled.</returns> public override bool injectMouseMove(InputEventSystem.MouseEventArgs e) { return(base.injectMouseMove(e)); }
/// <summary> /// Receives all MouseDown events, and checks if control is focused and /// should receive event. /// </summary> /// <param name="args">Mouse event arguments.</param> protected virtual void MouseDownIntercept(MouseEventArgs args) { if (this.Visible) { // Check coordinates as well because modal mode messes up the // MouseDown event. if (this.guiManager.GetFocus() == this && CheckCoordinates(args.Position.X, args.Position.Y) ) MouseDown.Invoke(args); } }
protected void OnButtonMouseOut(MouseEventArgs args) { if (!this.isListBoxOpen) this.button.CurrentSkinState = SkinState.Normal; }
/// <summary> /// Receives all MouseUp events, and checks if control is focused and /// should receive event. /// </summary> /// <param name="args">Mouse event arguments.</param> protected virtual void MouseUpIntercept(MouseEventArgs args) { if (this.Visible) { if (this.guiManager.GetFocus() == this) MouseUp.Invoke(args); } }
/// <summary> /// Closes popup menu if parent is a menu bar, and user has clicked /// enough times. /// </summary> /// <param name="args">Mouse event arguments.</param> protected override void MouseUpIntercept(MouseEventArgs args) { if (args.Button == MouseButtons.Left) { // Check that the mouse was depressed inside the button if (CheckCoordinates(args.Position.X, args.Position.Y)) { if (this.isPopUpShown && this.canClose) { this.numClicks++; if (this.numClicks > 1) { ClosePopUp(); AddHighlight(); } } } } }
/// <summary> /// Used for click event. Override to handle event. /// </summary> /// <param name="args">Mouse event arguments.</param> protected virtual void OnMouseDown(MouseEventArgs args) { if (args.Button == MouseButtons.Left) this.isPressed = true; }
/// <summary> /// Remove highlight. /// </summary> /// <param name="args">Mouse event arguments.</param> protected override void OnMouseOut(MouseEventArgs args) { base.OnMouseOut(args); if (!this.isPopUpShown) RemoveHighlight(); }
/// <summary> /// Updates button skin to reflect current mouse state. /// </summary> /// <param name="args">Mouse event arguments.</param> protected override void OnMouseDown(MouseEventArgs args) { base.OnMouseDown(args); if (args.Button == MouseButtons.Left) this.buttonBar.CurrentSkinState = SkinState.Pressed; }
/// <summary> /// Checks that the mouse position is inside the menu structure. If it /// isn't, then the menu is closed. /// </summary> /// <param name="args">Mouse event arguments.</param> protected void CheckMenuMouseStatus(MouseEventArgs args) { if (this.isPopUpShown) { bool onMenu = false; foreach (MenuItem item in this.menuItems) { if (item.CheckMenuCoordinates(args.Position.X, args.Position.Y)) { onMenu = true; break; } } // Check if menu should be closed if (!onMenu && this.selectedMenuItem != null) this.selectedMenuItem.ClosePopUp(); } }
/// <summary> /// Updates button skin to reflect current mouse state. /// </summary> /// <param name="args">Mouse event arguments.</param> protected override void OnMouseOut(MouseEventArgs args) { base.OnMouseOut(args); this.buttonBar.CurrentSkinState = SkinState.Normal; }
/// <summary> /// Close menu if mouse is released outside the menu structure. /// </summary> /// <param name="args">Mouse event arguments.</param> protected override void MouseUpIntercept(MouseEventArgs args) { CheckMenuMouseStatus(args); }
/// <summary> /// Updates button skin to reflect current mouse state. /// </summary> /// <param name="args">Mouse event arguments.</param> protected override void OnMouseOver(MouseEventArgs args) { base.OnMouseOver(args); if (IsPressed) this.buttonBar.CurrentSkinState = SkinState.Pressed; else this.buttonBar.CurrentSkinState = SkinState.Hover; }
/// <summary> /// Updates button skin to reflect current mouse state. /// </summary> /// <param name="args">Mouse event arguments.</param> protected override void OnMouseDown(MouseEventArgs args) { base.OnMouseDown(args); if (args.Button == MouseButtons.Left) { CurrentSkinState = SkinState.Pressed; if (this.isChecked) CurrentSkinState = SkinState.CheckedPressed; } }
/// <summary> /// Updates button skin to reflect current mouse state. /// </summary> /// <param name="args">Mouse event arguments.</param> protected override void OnMouseUp(MouseEventArgs args) { base.OnMouseUp(args); if (args.Button == MouseButtons.Left) { if (CheckCoordinates(args.Position.X, args.Position.Y)) this.buttonBar.CurrentSkinState = SkinState.Hover; else this.buttonBar.CurrentSkinState = SkinState.Normal; } }
/// <summary> /// Updates button skin to reflect current mouse state. /// </summary> /// <param name="args">Mouse event arguments.</param> protected override void OnMouseOver(MouseEventArgs args) { base.OnMouseOver(args); if (IsPressed) { CurrentSkinState = SkinState.Pressed; if (this.isChecked) CurrentSkinState = SkinState.CheckedPressed; } else { CurrentSkinState = SkinState.Hover; if (this.isChecked) CurrentSkinState = SkinState.CheckedHover; } }
/// <summary> /// Open listbox when button is pressed. /// </summary> /// <param name="args">Mouse event arguments.</param> protected void OnButtonMouseDown(MouseEventArgs args) { if (args.Button == MouseButtons.Left) { if (!this.isListBoxOpen && this.listBox.Count > 0) { this.listBox.X = AbsolutePosition.X; this.listBox.Y = AbsolutePosition.Y + Height - 1; this.listBox.Width = Width; GUIManager.Add(this.listBox); this.button.CurrentSkinState = SkinState.Pressed; this.isListBoxOpen = true; } else CloseListBox(); } }
/// <summary> /// Local MouseDown event handler. This function should inject this event /// to any components that check for input. /// </summary> /// <param name="e">Key event arguments</param> public override bool injectMouseDown(MouseEventArgs e) { return _user.injectMouseDown(e); }
/// <summary> /// Local MouseUp event handler. This function should inject this event /// to any components that check for input. /// </summary> /// <param name="e">Key event arguments</param> public override bool injectMouseUp(InputEventSystem.MouseEventArgs e) { return(_user.injectMouseUp(e)); }