From c73d5d74d056355a66b2544c7ece2ddbc3f3b8e1 Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Sat, 27 May 2023 20:32:51 +0200 Subject: [PATCH] Fix mouse wheel on NotificationsScroll (#9451) * Fix mouse wheel on NotificationsScroll * Explain why getMouseWheelX is overridden to zero --- .../ui/screens/worldscreen/NotificationsScroll.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/src/com/unciv/ui/screens/worldscreen/NotificationsScroll.kt b/core/src/com/unciv/ui/screens/worldscreen/NotificationsScroll.kt index 2d04660de6..7028d0c351 100644 --- a/core/src/com/unciv/ui/screens/worldscreen/NotificationsScroll.kt +++ b/core/src/com/unciv/ui/screens/worldscreen/NotificationsScroll.kt @@ -110,6 +110,16 @@ class NotificationsScroll( height = worldScreen.stage.height * inverseScaleFactor } + /** + * If a Gdx ScrollPane has content larger than its size on both dimensions (if only one axis is + * scrollable, the wheel will always scroll that axis), it will prefer mapping the mouse wheel + * to *horizontal* scrolling, which is not quite the best choice for our notifications. + * + * The intuitive approach might be to change the listener (by overriding [addScrollListener]), + * but luckily this works too. + */ + override fun getMouseWheelX() = 0f + /** Access to hidden "state" - writing it will ensure this is fully visible or hidden and the * restore button shown as needed - with animation. */ @Suppress("MemberVisibilityCanBePrivate") // API for future use