/// <summary> /// Handles the MouseWheelMoved event of the <see cref="GameBase.RenderWindow"/>. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="SFML.Window.MouseWheelEventArgs"/> instance containing the event data.</param> void rw_MouseWheelMoved(object sender, MouseWheelEventArgs e) { if (MouseWheelMoved != null) { MouseWheelMoved.Raise(this, e); } }
internal override void Update(GameTime gameTime) { _gameTime = gameTime; _currentState = Mouse.GetState(); CheckButtonPressed(s => s.LeftButton, MouseButton.Left); CheckButtonPressed(s => s.MiddleButton, MouseButton.Middle); CheckButtonPressed(s => s.RightButton, MouseButton.Right); CheckButtonPressed(s => s.XButton1, MouseButton.XButton1); CheckButtonPressed(s => s.XButton2, MouseButton.XButton2); CheckButtonReleased(s => s.LeftButton, MouseButton.Left); CheckButtonReleased(s => s.MiddleButton, MouseButton.Middle); CheckButtonReleased(s => s.RightButton, MouseButton.Right); CheckButtonReleased(s => s.XButton1, MouseButton.XButton1); CheckButtonReleased(s => s.XButton2, MouseButton.XButton2); // Check for any sort of mouse movement. if (_previousState.X != _currentState.X || _previousState.Y != _currentState.Y) { MouseMoved.Raise(this, new MouseEventArgs(gameTime.TotalGameTime, _previousState, _currentState)); } // Handle mouse wheel events. if (_previousState.ScrollWheelValue != _currentState.ScrollWheelValue) { MouseWheelMoved.Raise(this, new MouseEventArgs(gameTime.TotalGameTime, _previousState, _currentState)); } _previousState = _currentState; }
public override void Update(GameTime gameTime) { _gameTime = gameTime; CheckButtonPressed(s => s.LeftButton, MouseButton.Left); CheckButtonPressed(s => s.MiddleButton, MouseButton.Middle); CheckButtonPressed(s => s.RightButton, MouseButton.Right); CheckButtonReleased(s => s.LeftButton, MouseButton.Left); CheckButtonReleased(s => s.MiddleButton, MouseButton.Middle); CheckButtonReleased(s => s.RightButton, MouseButton.Right); // Check for any sort of mouse movement. if (HasMouseMoved) { MouseMoved?.Invoke(this, new MouseEventArgs(gameTime.TotalGameTime, _previousState, MouseState)); CheckMouseDragged(s => s.LeftButton, MouseButton.Left); CheckMouseDragged(s => s.MiddleButton, MouseButton.Middle); CheckMouseDragged(s => s.RightButton, MouseButton.Right); } // Handle mouse wheel events. if (_previousState.ScrollWheelValue != MouseState.ScrollWheelValue) { MouseWheelMoved?.Invoke(this, new MouseEventArgs(gameTime.TotalGameTime, _previousState, MouseState)); } _previousState = MouseState; }
private void _mouseListener_MouseWheelMoved(object sender, MouseEventArgs e) { _scene?.FireScroll(e); MouseWheelMoved?.Invoke(sender, e); #if DEBUG Logger.Log("Mouse wheel moved."); #endif }
/// <summary> /// Safely invokes the <see cref="MouseWheelMoved"/> event with the given <paramref name="args"/>. /// Protects against plugin thrown exceptions. /// </summary> /// <param name="args">The arguments to invoke the event with</param> void InvokeMouseWheelMoved(MouseWheelEventArgs args) { try { MouseWheelMoved?.Invoke(args); } catch (Exception e) { Urho.IO.Log.Write(LogLevel.Warning, $"There was an unexpected exception during the invocation of {nameof(MouseWheelMoved)}: {e.Message}"); } }
public InputEvents(RenderWindow window) { // if dummy don't attach events if (window == null) { return; } _window = window; _window.KeyPressed += (sender, args) => KeyPressed?.Invoke(sender, args); _window.KeyReleased += (sender, args) => KeyReleased?.Invoke(sender, args); _window.MouseButtonPressed += (sender, args) => MouseButtonPressed?.Invoke(sender, args); _window.MouseButtonReleased += (sender, args) => MouseButtonReleased?.Invoke(sender, args); _window.MouseMoved += (sender, args) => MouseMoved?.Invoke(sender, args); _window.MouseWheelMoved += (sender, args) => MouseWheelMoved?.Invoke(sender, args); _window.MouseEntered += (sender, args) => MouseEntered?.Invoke(sender, args); _window.MouseLeft += (sender, args) => MouseLeft?.Invoke(sender, args); _window.TextEntered += (sender, args) => TextEntered?.Invoke(sender, args); }
public InputEvents(CluwneWindow window) { // if dummy don't attach events if (window == null) { return; } SFML.Graphics.RenderWindow SWindow = window.SFMLWindow; SWindow.KeyPressed += (sender, args) => KeyPressed?.Invoke(sender, (KeyEventArgs)args); SWindow.KeyReleased += (sender, args) => KeyReleased?.Invoke(sender, (KeyEventArgs)args); SWindow.MouseButtonPressed += (sender, args) => MouseButtonPressed?.Invoke(sender, (MouseButtonEventArgs)args); SWindow.MouseButtonReleased += (sender, args) => MouseButtonReleased?.Invoke(sender, (MouseButtonEventArgs)args); SWindow.MouseMoved += (sender, args) => MouseMoved?.Invoke(sender, (MouseMoveEventArgs)args); SWindow.MouseWheelScrolled += (sender, args) => MouseWheelMoved?.Invoke(sender, (MouseWheelScrollEventArgs)args); SWindow.MouseEntered += (sender, args) => MouseEntered?.Invoke(sender, args); SWindow.MouseLeft += (sender, args) => MouseLeft?.Invoke(sender, args); SWindow.TextEntered += (sender, args) => TextEntered?.Invoke(sender, (TextEventArgs)args); }
/// <summary> /// /// </summary> /// <param name="gameTime"></param> public void Update(GameTime gameTime) { _gameTime = gameTime; _currentState = Mouse.GetState(); CheckButtonPressed(s => s.LeftButton, MouseButton.Left); CheckButtonPressed(s => s.MiddleButton, MouseButton.Middle); CheckButtonPressed(s => s.RightButton, MouseButton.Right); CheckButtonPressed(s => s.XButton1, MouseButton.XButton1); CheckButtonPressed(s => s.XButton2, MouseButton.XButton2); CheckButtonReleased(s => s.LeftButton, MouseButton.Left); CheckButtonReleased(s => s.MiddleButton, MouseButton.Middle); CheckButtonReleased(s => s.RightButton, MouseButton.Right); CheckButtonReleased(s => s.XButton1, MouseButton.XButton1); CheckButtonReleased(s => s.XButton2, MouseButton.XButton2); // Check for any sort of mouse movement. if (HasMouseMoved) { MouseMoved?.Invoke(this, new MouseEventArgs(ScreenTransformationMatrixProvider, gameTime.TotalGameTime, _previousState, _currentState)); CheckMouseDragged(s => s.LeftButton, MouseButton.Left); CheckMouseDragged(s => s.MiddleButton, MouseButton.Middle); CheckMouseDragged(s => s.RightButton, MouseButton.Right); CheckMouseDragged(s => s.XButton1, MouseButton.XButton1); CheckMouseDragged(s => s.XButton2, MouseButton.XButton2); } // Handle mouse wheel events. if (_previousState.ScrollWheelValue != _currentState.ScrollWheelValue) { MouseWheelMoved?.Invoke(this, new MouseEventArgs(ScreenTransformationMatrixProvider, gameTime.TotalGameTime, _previousState, _currentState)); } _previousState = _currentState; }