diff --git a/OpenRA.FileFormats/Graphics/IInputHandler.cs b/OpenRA.FileFormats/Graphics/IInputHandler.cs index 59b0a7a5ab..b3028aa18f 100755 --- a/OpenRA.FileFormats/Graphics/IInputHandler.cs +++ b/OpenRA.FileFormats/Graphics/IInputHandler.cs @@ -43,10 +43,12 @@ namespace OpenRA [Flags] public enum MouseButton { - None = (int)MouseButtons.None, - Left = (int)MouseButtons.Left, - Right = (int)MouseButtons.Right, - Middle = (int)MouseButtons.Middle, + None, + Left, + Right, + Middle, + WheelDown, + WheelUp } [Flags] diff --git a/OpenRA.Game/Widgets/ScrollPanelWidget.cs b/OpenRA.Game/Widgets/ScrollPanelWidget.cs index f39f805e3e..f6aa8e13e5 100644 --- a/OpenRA.Game/Widgets/ScrollPanelWidget.cs +++ b/OpenRA.Game/Widgets/ScrollPanelWidget.cs @@ -110,12 +110,16 @@ namespace OpenRA.Widgets return EventBounds; } + void Scroll(int direction) + { + ListOffset += direction*ScrollVelocity; + ListOffset = Math.Min(0,Math.Max(RenderBounds.Height - ContentHeight, ListOffset)); + } + public override void Tick () { - if (UpPressed && ListOffset <= 0) ListOffset += ScrollVelocity; - if (DownPressed) ListOffset -= ScrollVelocity; - - ListOffset = Math.Min(0,Math.Max(RenderBounds.Height - ContentHeight, ListOffset)); + if (UpPressed) Scroll(1); + if (DownPressed) Scroll(-1); } public override bool LoseFocus (MouseInput mi) @@ -127,6 +131,18 @@ namespace OpenRA.Widgets int2 lastMouseLocation; public override bool HandleInputInner(MouseInput mi) { + if (mi.Button == MouseButton.WheelDown) + { + Scroll(-1); + return true; + } + + if (mi.Button == MouseButton.WheelUp) + { + Scroll(1); + return true; + } + if (mi.Button != MouseButton.Left) return false; diff --git a/OpenRA.Game/Widgets/Widget.cs b/OpenRA.Game/Widgets/Widget.cs index a858d4a3d5..0614e6e968 100644 --- a/OpenRA.Game/Widgets/Widget.cs +++ b/OpenRA.Game/Widgets/Widget.cs @@ -194,7 +194,7 @@ namespace OpenRA.Widgets return EventBounds.Contains(pos.ToPoint()) ? GetCursor(pos) : null; } - public virtual bool HandleInputInner(MouseInput mi) { return !ClickThrough; } + public virtual bool HandleInputInner(MouseInput mi) { return !ClickThrough && mi.Button == MouseButton.Left; } public static bool HandleInput(MouseInput mi) { diff --git a/OpenRA.Renderer.Cg/GraphicsDevice.cs b/OpenRA.Renderer.Cg/GraphicsDevice.cs index 6ef5b5e530..0b057298fb 100755 --- a/OpenRA.Renderer.Cg/GraphicsDevice.cs +++ b/OpenRA.Renderer.Cg/GraphicsDevice.cs @@ -143,6 +143,8 @@ namespace OpenRA.Renderer.Cg return b == Sdl.SDL_BUTTON_LEFT ? MouseButton.Left : b == Sdl.SDL_BUTTON_RIGHT ? MouseButton.Right : b == Sdl.SDL_BUTTON_MIDDLE ? MouseButton.Middle + : b == Sdl.SDL_BUTTON_WHEELDOWN ? MouseButton.WheelDown + : b == Sdl.SDL_BUTTON_WHEELUP ? MouseButton.WheelUp : 0; } diff --git a/OpenRA.Renderer.Gl/GraphicsDevice.cs b/OpenRA.Renderer.Gl/GraphicsDevice.cs index 2ef2f834ac..f5de45c2d5 100755 --- a/OpenRA.Renderer.Gl/GraphicsDevice.cs +++ b/OpenRA.Renderer.Gl/GraphicsDevice.cs @@ -139,6 +139,8 @@ namespace OpenRA.Renderer.Glsl return b == Sdl.SDL_BUTTON_LEFT ? MouseButton.Left : b == Sdl.SDL_BUTTON_RIGHT ? MouseButton.Right : b == Sdl.SDL_BUTTON_MIDDLE ? MouseButton.Middle + : b == Sdl.SDL_BUTTON_WHEELDOWN ? MouseButton.WheelDown + : b == Sdl.SDL_BUTTON_WHEELUP ? MouseButton.WheelUp : 0; }