-
Notifications
You must be signed in to change notification settings - Fork 792
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
Fix stuck hover state #4724
Fix stuck hover state #4724
Conversation
"""Update the styles of the widget and its children when disabled is toggled.""" | ||
from .app import ScreenStackError | ||
|
||
if disabled and self.mouse_over: | ||
self._message_queue.put_nowait(events.Leave()) |
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 block all makes sense to me other than posting the Leave
event, because the mouse has not left the widget.
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's because when a widget is disabled, it no longer receives Enter and Leave events. So a widget that is hovered and programmatically disabled will have received an Enter, but will never get a corresponding Leave. So whatever the widget does on enter is stuck even if the cursor is no longer over the widget.
Sending the Leave here ensures that the widget goes back to its unhovered state when disabled.
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.
Makes sense after the explanation in the first paragraph, thanks. Probably worth a small update to the Leave docstring.
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.
Done
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 think we should avoid posting a Leave
event, as it feels like a workaround and the events are part of the public API. There's probably a way we could do this internally?
Fixes #3130