/// <summary> /// Determines if the specified button is currently pressed. /// </summary> /// <param name="state">The MouseState which should be checked.</param> /// <param name="button">The MouseButton which should be checked.</param> /// <returns>Returns true if the button is currently pressed, false otherwise.</returns> private static bool IsDown(MouseState state, MouseButton button) { return IsButtonState(state, button, ButtonState.Pressed); }
/// <summary> /// Determines if the specified button is currently released. /// </summary> /// <param name="state">The MouseState which should be checked.</param> /// <param name="button">The MouseButton which should be checked.</param> /// <returns>Returns true if the button is currently released, false otherwise.</returns> private static bool IsUp(MouseState state, MouseButton button) { return IsButtonState(state, button, ButtonState.Released); }
/// <summary> /// Determines if the specified MouseButton has the expected ButtonState value. /// </summary> /// <param name="mouseState">The MouseState which should be checked.</param> /// <param name="mouseButton">The MouseButton which should be checked.</param> /// <param name="buttonState">The expected ButtonState value.</param> /// <returns></returns> private static bool IsButtonState(MouseState mouseState, MouseButton mouseButton, ButtonState buttonState) { return mouseButton.HasState(mouseState, buttonState); }
/// <summary> /// Determines if the specified button is actively being held down. /// </summary> /// <param name="button">The button whose state should be checked.</param> /// <returns>True if the button is currently being held down, false otherwise.</returns> public bool IsCurrentlyPressed(MouseButton button) { return IsDown(_MouseState, button); }
/// <summary> /// Determines if the specified button used to be pressed, but isn't currently pressed. /// </summary> /// <param name="button">The button whose state should be checked.</param> /// <returns>True if the button has been recently released, false otherwise.</returns> public bool HasBeenReleased(MouseButton button) { return IsUp(_MouseState, button) && IsUp(_LastMouseState, button); }
/// <summary> /// Determines if the specified button is currently pressed, but used to not be pressed. /// </summary> /// <param name="button">The button whose state should be checked.</param> /// <returns>True if the button has been recently pressed, false otherwise.</returns> public bool HasBeenPressed(MouseButton button) { return IsDown(_MouseState, button) && IsUp(_LastMouseState, button); }
/// <summary> /// Determines if the specified button has been pressed and released twice in quick succession. /// </summary> /// <param name="button">The button whose state should be checked.</param> /// <returns>True if the button has been recently double clicked, false otherwise.</returns> public bool HasBeenDoubleClicked(MouseButton button) { MouseActionTracker clickOptions; if (_MouseActions.TryGetValue(button, out clickOptions) == false) { return false; } return clickOptions.LastClickWasConsideredDoubleClick; }