diff --git a/src/main/kotlin/online/hudacek/fxradio/ui/view/library/LibrarySearchView.kt b/src/main/kotlin/online/hudacek/fxradio/ui/view/library/LibrarySearchView.kt index 9ce7dbf..957571b 100644 --- a/src/main/kotlin/online/hudacek/fxradio/ui/view/library/LibrarySearchView.kt +++ b/src/main/kotlin/online/hudacek/fxradio/ui/view/library/LibrarySearchView.kt @@ -25,6 +25,7 @@ import online.hudacek.fxradio.ui.util.keyCombination import online.hudacek.fxradio.ui.util.make import online.hudacek.fxradio.ui.util.requestFocusOnSceneAvailable import online.hudacek.fxradio.ui.util.searchField +import online.hudacek.fxradio.util.Modal import online.hudacek.fxradio.viewmodel.LibraryState import online.hudacek.fxradio.viewmodel.LibraryViewModel import online.hudacek.fxradio.viewmodel.SearchViewModel @@ -65,8 +66,10 @@ class LibrarySearchView : BaseView() { } shortcut(keyCombination(KeyCode.F)) { - requestFocusOnSceneAvailable() - setSearchState(text) + if (!Modal.isAnyFragmentOpen()) { + requestFocusOnSceneAvailable() + setSearchState(text) + } } validator { diff --git a/src/main/kotlin/online/hudacek/fxradio/ui/view/player/PlayerView.kt b/src/main/kotlin/online/hudacek/fxradio/ui/view/player/PlayerView.kt index 3c5ed34..764a21f 100644 --- a/src/main/kotlin/online/hudacek/fxradio/ui/view/player/PlayerView.kt +++ b/src/main/kotlin/online/hudacek/fxradio/ui/view/player/PlayerView.kt @@ -107,8 +107,10 @@ class PlayerView : BaseView() { } shortcut(keyCombination(KeyCode.I)) { - if (selectedStationViewModel.stationProperty.value.isValid()) { - isSelected = !isSelected + if (!Modal.isAnyFragmentOpen()) { + if (selectedStationViewModel.stationProperty.value.isValid()) { + isSelected = !isSelected + } } } diff --git a/src/main/kotlin/online/hudacek/fxradio/util/Modal.kt b/src/main/kotlin/online/hudacek/fxradio/util/Modal.kt index 9b992f2..9fd1ccf 100644 --- a/src/main/kotlin/online/hudacek/fxradio/util/Modal.kt +++ b/src/main/kotlin/online/hudacek/fxradio/util/Modal.kt @@ -52,6 +52,13 @@ sealed class Modal( data object Preferences : Modal() data object OpenStream : Modal() data object Countries : Modal() + + companion object { + /** + * Returns true if any [Fragment] is currently present in the scene + */ + fun isAnyFragmentOpen() = FX.primaryStage.scene.findUIComponents().any { it is Fragment } + } } /**