You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR adds a much more complicated example for defining transition rules, as well as significantly changing the wording.
The old documentation was not enough for me to understand how to define the rules, so this took some trial and error. I believe that the documentation in the PR would have made things more clear from the start.
Copy file name to clipboardexpand all lines: docs/src/live/app_intro.md
+18-8
Original file line number
Diff line number
Diff line change
@@ -110,13 +110,23 @@ To change the currently active widget you can "navigate" through the app using a
110
110
To test this, use `play` on the app we just created and then left/right arrow to change focus!
111
111
(Don't forget to use `q` to exit the app when you're done)
112
112
113
-
Sometimes you want different ways to specify which widget should be active, either by using an arrow key or by pressing a specific key.
114
-
You can pass `transition_rules` to `App` to use your own set of rules. `transition_rules` should be a `Dict` with `KeyInput` types as key and a `Dict` of pairs `Symbol => Symbol`. The interpretation is that the symbols indicate the current and next widget to be active when the key is pressed. For example:
115
-
116
-
```julia
117
-
transition_rules =Dict(
118
-
ArrowRight() =>Dict(:a=>:b),
119
-
ArrowLeft() =>Dict(:b=>:a),
113
+
### Activating widgets by keyboard input
114
+
Sometimes you want different ways to specify which widget should be active, either by using an arrow key or by pressing a specific key. While there are some defaults for simple apps, you will likely need to specify these "transition rules" manually for most layouts. This is done by passing a `Dict` as the keyword argument `transition_rules` when you create your `App`. The keys of `transition_rules` should be of type `KeyInput`, and the values should of type `Dict`, mapping symbols to symbols. The wording can get complicated with these nested dictionaries, so the example below hopefully explains how to define apropriate transition rules:
115
+
```
116
+
App(
117
+
# Layout: 3 columns (a b c), with b split in the middle
implements the transition rules from the example above.
132
+
To mentally parse the first transition rule, you should think "When ArrowRight is pressed, if :a is selected, move to :b1. If :b1 is selected, move to :c. If :b2 is selected, move to :c."
0 commit comments