public virtual void HandleMouse(DeltaMouseState mouseState) { if (Bounds.Contains(mouseState.Location)) { if (mouseState.DoubleClicked) { OnMouseDoubleClicked(mouseState); } if (mouseState.LeftButton == ButtonDelta.Pressed) { OnMousePressed(mouseState); } if (mouseState.LeftButton == ButtonDelta.Down) { OnMouseDown(mouseState); } if (mouseState.LeftButton == ButtonDelta.Released) { OnMouseUp(mouseState); } if (mouseState.RightButton == ButtonDelta.Pressed) { OnRightMousePressed(mouseState); } if (mouseState.RightButton == ButtonDelta.Down) { OnRightMouseDown(mouseState); } if (mouseState.RightButton == ButtonDelta.Released) { OnRightMouseUp(mouseState); } } }
public override void HandleMouse(DeltaMouseState mouseState) { base.HandleMouse(mouseState); for (int index = 0; index < myChildControls.Length; index++) { if (myChildControls[index].Bounds.Contains(mouseState.Location)) { myChildControls[index].HandleMouse(mouseState); } } }
public override void HandleMouse(DeltaMouseState mouseState) { base.HandleMouse(mouseState); if (mouseState.LeftButton == ButtonDelta.Released) { isHoldingHorizontalScroll = false; isHoldingVerticalScroll = false; } if (isHoldingVerticalScroll) { float deltaY = mouseState.DeltaY; if (deltaY != 0) { myScrollY += (deltaY / myScrollableHeight); } myScrollY = MathHelper.Clamp(myScrollY, 0, 1); __CalculateScrollerBounds(); } else if (isHoldingHorizontalScroll) { float deltaX = mouseState.DeltaX; if (deltaX != 0) { myScrollX += (deltaX / myScrollableWidth); } myScrollX = MathHelper.Clamp(myScrollX, 0, 1); __CalculateScrollerBounds(); } if (Bounds.Contains(mouseState.Location)) { if (mouseState.LeftButton == ButtonDelta.Pressed) { if (isHorizontalScrollVisible && myHorizontalScrollerBounds.Contains(mouseState.Location - Location)) { isHoldingHorizontalScroll = true; } else if (isVerticalScrollVisible && myVerticalScrollerBounds.Contains(mouseState.Location - Location)) { isHoldingVerticalScroll = true; } } if (mouseState.DeltaScroll != 0) { if (!KeyboardManager.IsDown(Keys.LeftShift)) { myScrollY -= ((float)mouseState.DeltaScroll / myInternalHeight) * (Bounds.Height / myInternalHeight); myScrollY = MathHelper.Clamp(myScrollY, 0, 1); } else { myScrollX += ((float)mouseState.DeltaScroll / myInternalWidth) * (Bounds.Width / myInternalWidth); myScrollX = MathHelper.Clamp(myScrollX, 0, 1); } __CalculateScrollerBounds(); } } }
protected virtual void OnRightMouseUp(DeltaMouseState mouseState) { RightMouseReleased?.Invoke(this, mouseState); }
protected virtual void OnRightMouseDown(DeltaMouseState mouseState) { RightMouseDown?.Invoke(this, mouseState); }
protected virtual void OnRightMousePressed(DeltaMouseState mouseState) { RightMousePressed?.Invoke(this, mouseState); }
protected virtual void OnMouseDoubleClicked(DeltaMouseState mouseState) { MouseDoubleClick?.Invoke(this, mouseState); }