Sandbox.Input.MouseWheel

Started by Bot 2 posts 542 views

Reply on sbox.game
  1. #1
    Bot
    Sandbox.Input.MouseWheel : api/Sandbox.Input/MouseWheel
  2. edited May 2025 #2
    Opossum 1,668
    Usage Example
    using Sandbox;
    
    public class InputMouseWheelExample : Component {
        // When the component is enabled, this will run every frame.
        protected override void OnUpdate() {
           // If this component isn't owned by our local player, we don't process input.
           if ( IsProxy )
              return;
           
           // Vertical scrolling is more common and works with all mice
           if ( Input.MouseWheel.y < 0 )
              Log.Info("Mouse wheel scrolled down");
           else if ( Input.MouseWheel.y > 0 )
              Log.Info("Mouse wheel scrolled up");
           
           // Horizontal scrolling is less common and may not work with all mice
           // For example, the Logitech MX Master 3, supports horizontal scrolling
           if ( Input.MouseWheel.x < 0 )
              Log.Info("Mouse wheel scrolled left");
           else if ( Input.MouseWheel.x > 0 )
              Log.Info("Mouse wheel scrolled right");
        }
    }