From 03579a884deb2e8475cc64c62aa4abd5f4a97b8e Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Sun, 15 May 2022 01:11:15 +0200 Subject: [PATCH] Fix TabbedPager stealing arrow keys from TextFields (#6809) --- core/src/com/unciv/ui/utils/TabbedPager.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/com/unciv/ui/utils/TabbedPager.kt b/core/src/com/unciv/ui/utils/TabbedPager.kt index 1d15937f2f..f2ce1a2be6 100644 --- a/core/src/com/unciv/ui/utils/TabbedPager.kt +++ b/core/src/com/unciv/ui/utils/TabbedPager.kt @@ -453,12 +453,12 @@ open class TabbedPager( * Caller is responsible for cleanup if necessary. */ fun bindArrowKeys() { if (keyPressDispatcher == null) return - fun cyclePage(direction: Int) { - if (activePage == -1) return - selectPage((activePage + direction).coerceIn(0 until pages.size)) + fun cyclePageFactory(direction: Int): ()->Unit = { + if (activePage != -1 && (stage.keyboardFocus == null || hasKeyboardFocus())) + selectPage((activePage + direction).coerceIn(pages.indices)) } - keyPressDispatcher[KeyCharAndCode(Input.Keys.LEFT)] = { cyclePage(-1) } - keyPressDispatcher[KeyCharAndCode(Input.Keys.RIGHT)] = { cyclePage(1) } + keyPressDispatcher[KeyCharAndCode(Input.Keys.LEFT)] = cyclePageFactory(-1) + keyPressDispatcher[KeyCharAndCode(Input.Keys.RIGHT)] = cyclePageFactory(1) } /** Remove a page by its index.