Use of main app bindings in Modal Screen #5777
nannerpusser
started this conversation in
General
Replies: 1 comment 1 reply
-
No. This is explained in the Modal screen docs: https://textual.textualize.io/guide/screens/#modal-screens
You would need to prefix the actions with the app namespace to run actions on the App. For example, |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Before I get too far into the weeds and open any official reports I'm curious if my main app's bindings are meant to still function while in a temporary/secondary Screen, specifically a Modal sitting on top of the main screen. The Modal is called with
push_screen()
and eventually removed using apop_screen()
if it matters. Code example:class SplackApp(App):
BINDINGS = [("ctrl+q", "quit", "Quit"), ("f1", "toggle_sidebar", "Open Sidebar")]
def __init__(self) -> None:
super().__init__()
self.thing = wooptywoo(otherthing.whatever=x, okcool=True)
def thing_pushing_screen(var1, var2, xxyy=zz):
blah, code here # sweet code bro
self.push_screen(PlayScreen(more blah blah variables)
class PlayerScreen(ModalScreen):
CSS_PATH = "style.tcss"
BINDINGS = [Binding("ctrl+q", "quit", "Quit", show=False, priority=True)]
Sorry for the formatting without indentation, but I cannot get this editor to behave. Code works great and I can pop the screen and go back to the main app with a close Button and it all works as it should, except I cannot use any bindings while the modal is on top. I have tried defining its own separate bindings, changing priority, changing the actual keys used. I was going to define my own key binds that also function as bindings for another library that is being used with the modal (python-mpv) so that if I Ctrl + Q while on the PlayerScreen modal it does it safely by shutting down mpv first, then popping the screen. But I can't find this specific use in the docs (keybindings on modal screens).
Beta Was this translation helpful? Give feedback.
All reactions