private void splitter_MouseDown(object sender, MouseEventArgs e) { if (SplitterVisible && !ButtonRectangle.Contains(e.Location) && !Collapsed && !IsSplitterFixed) { m_trackingMouse = true; } }
public virtual void OnMouseMove(MouseEventArgs e) { bool hover = ButtonRectangle.Contains(e.X, e.Y); if (hover != isHover) { isHover = hover; this.Invalidate(ButtonRectangle); } else if (isDrag) { Point oldPt = dragPt; dragPt = e.Location; Rectangle rc = this.Bounds; Point pt = this.Location; pt.X += dragPt.X - oldPt.X; pt.Y += dragPt.Y - oldPt.Y; Rectangle invalidRect = Rectangle.Union(this.bounds_, rc); this.Location = pt; this.Invalidate(invalidRect); } }
public override void Update() { if (ButtonRectangle.Contains(Input.MousePosition.ToPoint()) && Input.WasLeftMouseClicked()) { ZombieGame.SetQuit = true; } }
public override void Update() { if (ButtonRectangle.Contains(Input.MousePosition.ToPoint()) && Input.WasLeftMouseClicked()) { Console.WriteLine("Triggered"); } }
public bool IsClicked() { if (InputManager.LeftButtonIsClicked()) { if (!ButtonRectangle.Intersects(InputManager.MouseRectangle)) { IsLocked = true; } else if (ButtonRectangle.Intersects(InputManager.MouseRectangle) && !IsOnHold && !IsLocked) { IsOnHold = true; return(false); } } else if (!InputManager.LeftButtonIsClicked()) { IsLocked = false; if (!ButtonRectangle.Intersects(InputManager.MouseRectangle)) { IsOnHold = false; } else if (IsOnHold && ButtonRectangle.Intersects(InputManager.MouseRectangle)) { IsOnHold = false; return(true); } } return(false); }
private bool IsMouseOverExpandCollapseRegion(Point mouseLocation) { if (!ButtonRectangle.Contains(mouseLocation) && !Collapsed) { return(IsSplitterFixed); } return(true); }
public virtual void OnMouseUp(MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (isPushed && ButtonRectangle.Contains(e.X, e.Y)) { IsCollapsed = !IsCollapsed; } isDrag = false; isPushed = false; } }
public virtual void Update(GameTime gameTime) { if (!ButtonRectangle.Intersects(InputManager.MouseRectangle)) { IdleMouseOver = false; } else { IdleMouseOver = true; } UpdateTransparency(IsOnHold); if (IdleMouseOver || (OffSet != 0)) { UpdateOffSet(gameTime.ElapsedGameTime.Milliseconds); } }
/// <summary> /// Updates the button's colour based on the cursor's position. /// </summary> /// <param name="mState"> /// The MouseState variable whose input is to be queried. /// </param> /// /// <param name="prevMState"> /// The previous mouse state. Used to query for single clicks. /// </param> /// mState used as a parameter because it is not needed elsewhere in the /// class. This can then be passed in within Game1, and other /// classes which use Buttons then don't need to handle mouse input. public void Update(MouseState mState, MouseState prevMState) { // Button colour FSM // Uses if-statements because multiple conditions are checked for. // Contains can either lead to hovering or clicking... if (ButtonRectangle.Contains(mState.Position)) { // ...so nested ifs are used to address all conditions // Click and hold: click colour is shown ONLY. if (mState.LeftButton == ButtonState.Pressed) { CurrentButtonColour = ClickButtonColour; } // Release after click: button registers as clicked. else if (mState.LeftButton == ButtonState.Released && prevMState.LeftButton == ButtonState.Pressed) { IsClicked = true; } // If neither of the above take place, then the user is hovering. else { CurrentButtonColour = HoverButtonColour; IsClicked = false; } // Above was written as a single conditional, and not broken up // into multiple ones because events are mutually exclusive. // Therefore, only split conditionals into multiple if's when // events are NOT mututally exclusive i.e. they can occur // simultaneously. } // If Contains returns false, the user is neither hovering or // clicking on the button else { CurrentButtonColour = DefaultButtonColour; IsClicked = false; } }
public virtual void OnMouseDown(MouseEventArgs e) { if (e.Button == MouseButtons.Left) { isPushed = ButtonRectangle.Contains(e.X, e.Y); if (!isPushed && e.Clicks == 2 && CaptionRectangle.Contains(e.X, e.Y)) { // ダブルクリックで閉じる IsCollapsed = !IsCollapsed; } else if (this.CaptionRectangle.Contains(e.Location)) { dragPt = e.Location; isDrag = true; } } else { isPushed = false; } }