Skip to content
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

Merged
merged 6 commits into from
Jul 11, 2024
Merged

Fix stuck hover state #4724

merged 6 commits into from
Jul 11, 2024

Conversation

willmcgugan
Copy link
Collaborator

Fixes #3130

@willmcgugan willmcgugan changed the title disable button Fix stuck hiver Jul 11, 2024
@willmcgugan willmcgugan changed the title Fix stuck hiver Fix stuck hover state Jul 11, 2024
"""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())
Copy link
Member

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.

Copy link
Collaborator Author

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.

Copy link
Member

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member

@darrenburns darrenburns left a 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?

@willmcgugan willmcgugan merged commit 27def7b into main Jul 11, 2024
20 checks passed
@willmcgugan willmcgugan deleted the disable-button branch July 11, 2024 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Button background stuck in hover style if disabled programatically
2 participants