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.


Part of this is discussed in #145 but here is my motivation for the changes:
The Dom doesn't need to be involved in requesting focus. The only utility it provided here was to be globally available. Selection happens on input, and affects only other input, so we treat it as input.
Having the current selection available in InputState lets us more consistently clear selection on mouse clicks. Clear selection on mousedown, then let widgets capturing the mousedown set selected again. This removes a FIXME in the code and makes it so e.g. textboxes get blurred when you click a button.
To not regress in features, add a new API through
Yakuito request focus. This is done through a newEvent, matching the model of how changes are passed from application state to input state.Autofocus was using a special WidgetResponse API (plus
pending_request_focusinDom) to request focus on a widget ID. This doesn't need to be a first class feature. The model for passing widget results back as input for the next frame in yakui is to track the state externally and pass it in next frame. Yakui wasn't providing any utility here that you can't implement as a user, and it was coming at the cost of added complexity to some clean APIs (DomandResponse).In the case of the autofocus example I implemented it as a basic callback list in ExampleState, for general utility. But in user code this could be a thread local, a
Option<WidgetId>, or whatever.