trophy 0
May 2025 21 posts
Sandbox.Input.MouseWheel : api/Sandbox.Input/MouseWheel
trophy 1648
Apr 2021 11 posts
Opossum one month ago edited one month ago
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");
    }
}
people
Log in to reply
You can't reply if you're not logged in. That would be crazy.