Skip to content

Commit 8b99b3f

Browse files
committed
PR feedback
1 parent f03f038 commit 8b99b3f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

docs/guide/widgets.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,9 @@ which let them call [actions](../guide/actions.md) in response to key presses.
197197

198198
A widget is only able to handle key presses if it or one of its descendants has [focus](../guide/input.md#input-focus).
199199

200-
To demonstrate, let's design a simple interactive counter widget which can be incremented and decremented using the keyboard.
201-
202-
In the following example, we define a simple `Counter` widget with `can_focus=True`, and some CSS to make it stand out when focused.
203-
Our app contains three `Counter` widgets, which we can focus by clicking or using ++tab++ and ++shift+tab++.
200+
Widgets aren't focusable by default.
201+
In order to allow a widget to be focused, we need to set `can_focus=True` when defining a widget subclass.
202+
Let's look at an example of defining a `Counter` widget which can be focused.
204203

205204
=== "counter01.py"
206205

@@ -223,6 +222,9 @@ Our app contains three `Counter` widgets, which we can focus by clicking or usin
223222
```{.textual path="docs/examples/guide/widgets/counter01.py"}
224223
```
225224

225+
226+
Our app contains three `Counter` widgets, which we can focus by clicking or using ++tab++ and ++shift+tab++.
227+
226228
Now that our counter is focusable, let's make it interactive by adding some key bindings and actions to it.
227229
To do this, we add a `BINDINGS` class variable to `Counter`, with bindings for ++up++ and ++down++.
228230
These new bindings are linked to the `change_count` action, which updates the `count` reactive attribute.

0 commit comments

Comments
 (0)