From ab4898dac3bdc1aba18bb0f01c8895397f9a79b9 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Fri, 20 Feb 2026 18:16:15 +0000 Subject: [PATCH] prevent keypresses from ConfigScreen propogating to the mainframe improve the error message should a command execution fail. --- src/q3rcon_tui/tui.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/q3rcon_tui/tui.py b/src/q3rcon_tui/tui.py index ac007f5..e565bb5 100644 --- a/src/q3rcon_tui/tui.py +++ b/src/q3rcon_tui/tui.py @@ -26,6 +26,10 @@ class RconApp(App): ) async def on_key(self, event) -> None: + # prevent keypresses from ConfigScreen from triggering actions in RconApp + if self.screen and isinstance(self.screen, ConfigScreen): + return + match event.key: case 'enter' if self.query_one('#command', Input).has_focus: self.query_one('#send', Button).press() @@ -64,9 +68,14 @@ class RconApp(App): self.query_one('#response', RichLog).write( self.writable.parse(cmd, response) ) - except RCONError as e: + except RCONError: + output = ( + 'Unable to execute command.', + 'It may be due to a map change or a server restart.', + 'If the problem persists, please check your connection settings and ensure the server is running.', + ) self.query_one('#response', RichLog).write( - f'{type(e).__name__}: Unable to connect to server: is the server running and are the host, port, and password correct? ({e})' + self.writable.error('\n'.join(output)) ) self.query_one('#command', Input).value = ''