Improve flexibility of PaneGrid
#608
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current
PaneGrid
widget implicitly manages and exposes pane focus state without producing application messages.This is generally forbidden. Meaningful application state changes that can trigger differences in the widget tree should always happen as a result of message processing and its respective call to
Application::update
.After merging #597, this design flaw has become very apparent and the
pane_grid
example does not work as expected anymore.This PR fixes the design of the
PaneGrid
widget while, at the same time, simplifying its API and making it more flexible overall. Specifically:PaneGrid
does not know about any kind of pane focus.on_click
event handler has been added toPaneGrid
. This handler can be used to reproduce and extend the old focus functionality on top of application code.on_key_press
handler has been removed. Instead, it is recommended to usesubscription::events
or the brand newsubscription::events_with
in order to listen to keyboard events.As usual, the
pane_grid
example has been updated to showcase how to use this new API. It should reproduce the old behavior (prior to merging #597).