Skip to content

Commit 014fe42

Browse files
committed
Focus the directory tree
1 parent 93e75f3 commit 014fe42

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

examples/code_browser.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
from rich.syntax import Syntax
1313
from rich.traceback import Traceback
14+
15+
from textual import events
1416
from textual.app import App, ComposeResult
1517
from textual.containers import Container, Vertical
1618
from textual.reactive import var
@@ -30,7 +32,7 @@ class CodeBrowser(App):
3032

3133
def watch_show_tree(self, show_tree: bool) -> None:
3234
"""Called when show_tree is modified."""
33-
self.set_class(show_tree, "-show-tree")
35+
self.set_class(show_tree, "-show-tree")
3436

3537
def compose(self) -> ComposeResult:
3638
"""Compose our UI."""
@@ -42,6 +44,9 @@ def compose(self) -> ComposeResult:
4244
)
4345
yield Footer()
4446

47+
def on_mount(self, event: events.Mount) -> None:
48+
self.query_one(DirectoryTree).focus()
49+
4550
def on_directory_tree_file_click(self, event: DirectoryTree.FileClick) -> None:
4651
"""Called when the user click a file in the directory tree."""
4752
code_view = self.query_one("#code", Static)

0 commit comments

Comments
 (0)