Input widget and auto focus disabling #4143
-
Hi, I've started playing with Textual and am making a small app with a UI that is split into three boxes, two on the left side and one on the right side. You can see this in the attached image. When the app starts, however, the search input box automatically gets focus, and so it is hard to test out other bindings. Is there a way to stop this from happening? I've added the button below so I can tab out and continue testing, but for the life of me I don't know how to just have it not take focus. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
You can disable auto-focus on the App or Screen with the
from textual.app import App, ComposeResult
from textual.widgets import Input
class NoAutoFocusApp(App):
AUTO_FOCUS = ""
def compose(self) -> ComposeResult:
yield Input()
if __name__ == "__main__":
app = NoAutoFocusApp()
app.run() |
Beta Was this translation helpful? Give feedback.
-
Well, I knew that there had to be something in the framework for this. Thank you @TomJGooding this works! |
Beta Was this translation helpful? Give feedback.
You can disable auto-focus on the App or Screen with the
AUTO_FOCUS
attribute.