-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
masonry: set pointer-captured ancestors of hover target as hot #572
Conversation
Currently when a widget has pointer capture and the pointer is over one of its descendants, no widget is considered hot. This changes the hot logic such that the widget with the pointer capture and its ancestors are are considered hot, but not its descendants.
next_hovered_path | ||
.into_iter() | ||
.skip_while(|id| *id != capture_target) | ||
.collect() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a potentially expensive memory operation that might be avoidable. We could short-circuit if there is a pointer capture target by traversing up the tree from that target, and then traverse downwards again to determine whether the pointer is inside the widget's and its ancestors' layout boxes. The search with find_widget_at_pos
is then also unnecessary.
(For keyboard focus, the focus chain is kept in the widget state, something similar could be considered for pointer capture targets.)
I think the current design is closer to right. Part of the problem is that child label widgets are currently used to implement text layout for buttons and checkboxes, but really, button and checkboxes should fundamentally be unified widgets without children. |
I guess that makes sense, with |
We could probably rename it, it's not a great name. |
I'd suggest closing this PR and renaming |
I agree.
An alternative to unified widgets, could be to generalize |
Yeah, I do see the appeal. "Non-interactive" would basically be a top-down flag like "disabled" and "stashed" currently work. |
Currently when a widget has pointer capture and the pointer is over one of its descendants, no widget is considered hot. This changes the hot logic such that the widget with the pointer capture and its ancestors are considered hot, but not its descendants.
The current behavior is troublesome. For example, when applying the following patch, a button does not register as having been pressed when the pointer is pressed while over its descendant label. That's because during the
PointerUp
event, the button is not considered hot (it has captured the pointer, but the pointer is not directly over the button: it's over its descendant label).