-
Notifications
You must be signed in to change notification settings - Fork 570
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
ZStack fix #2291
ZStack fix #2291
Conversation
…handled is called - add event.is_pointer_event()
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.
Thanks! I guess figuring out the status of wheel isn't super critical, since mouse up/down are much more important.
This conversation has made me realize, though, that I don't really understand exactly when it's appropriate to set_handled
...
ctx.set_handled(); | ||
if event.is_pointer_event() && previous_hot { | ||
if layer.child.is_active() { | ||
ctx.set_handled(); |
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.
Do we still need this set_handled
? Given your point about set_handled
affecting the rest of the widget tree, it seems maybe better to avoid it?
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.
Do you mean replace it with the obstructed
flag or just remove it?
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.
There's a good chance I'm missing something, but I was thinking just remove it. Does that work?
I'm expecting that this child is active but not hot, and it will know how to correctly handle mouse events based on that, even if they aren't marked as handled.
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.
I'm expecting that this child is active but not hot, and it will know how to correctly handle mouse events based on that, even if they aren't marked as handled.
The child only knows that it is not hot because it received a follow up event (Mouse event while active is set) which was marked as ´handled´.
In any case we either need set_handled
or obstructed
.
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.
Can't the child do ctx.is_hot()
?
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.
It is about the Pod
not the widget. The Pod
sees a mouse event inside its bounds. Therefore it sets its hot
state to true
. The only exception is that active
and hot
are both set. In that case the Pod
sets hot
to false
but still propagates the event.
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.
You mean handled
and not active
, right? So in that case I understand why you need set_handled
here, thanks for the explanation! I still think it isn't ideal because (as you explained in some other thread) it affects the global widget tree and not just the subtree under the zstack. But I don't think figuring it out needs to block this pr...
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.
Ups my mistake. I meant active
and set_handled
. In this case hot
is set to false
even if the curser is inside the widgets bounds
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.
I still think it isn't ideal because (as you explained in some other thread) it affects the global widget tree and not just the subtree under the zstack. But I don't think figuring it out needs to block this pr...
I aggree. The only thing which is still brocken is scrolling while pressing a mousebutton. That is not the most impprtant usecase. I think we can merge this PR as it is.
Event::Wheel is now a pointer event, which is probably the easiest solution. |
- update example
This PR makes it possible for a parent widget to use mouse events (for an example scrolling) while hovering over a
ZStack
.TODOs: