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

26645: Fixed Undo/Redo buttons' hover state when disabled #26671

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

krasko78
Copy link
Contributor

@krasko78 krasko78 commented Feb 21, 2025

Resolves: #26645

Key points:

  1. Added && root.enabled to the condition for the "HOVERED" state.
  2. Did the same for the "PRESSED" state for consistency although it wasn't needed for this issue.
  3. Removed enabled: root.enabled from the MouseArea since it has side effects. See below.
  4. As a consequence of 3. I also added && root.enabled to the tooltip display so it does not appear when the button is disabled which is the current behavior although there is a story to re-enable tooltips for disabled elements: Make disabled buttons focusable & show their tooltips on hover #26232

Disabling the MouseArea together with the button has side effects when the button is disabled upon its own click. This is the case with the Undo and Redo buttons when there are no more actions to undo/redo. In particular containsMouse of the MouseArea remains true when the button and its MouseArea get disabled. This means that the "HOVERED" state will remain active. This could be worked around by adding && mouseArea.enabled to the condition of the "HOVERED" state.

However, there is more: containsMouse will continue to be true even if the mouse then leaves the now disabled button. Let's say this is the Undo button and it becomes disabled on click since there are no more actions to undo. The user moves the mouse away from it and over the Redo button. containsMouse of the Undo button's MouseArea continues to be true since both the button and the MouseArea are now disabled and the MouseArea does not react to any mouse events any more. If the Redo button is now clicked, this will re-enable the Undo button and its MouseArea. The Undo button's "HOVERED" state will fire even though the mouse is hovering the Redo button.

The conclusion for me is we should not be disabling the MouseArea. Instead we should be checking root.Enabled where necessary. Again, #26232 is probably another reason to not disable the MouseAreas. The disabling of the MouseArea-s was done for #25697.

@cbjeukendrup What are your thoughts? Should we revert the disabling of all the MouseAreas and add '&& .enabled' where necessary? Or do you see a better approach?

  • I signed the CLA
  • The title of the PR describes the problem it addresses
  • Each commit's message describes its purpose and effects, and references the issue it resolves
  • If changes are extensive, there is a sequence of easily reviewable commits
  • The code in the PR follows the coding rules
  • There are no unnecessary changes
  • The code compiles and runs on my machine, preferably after each commit individually
  • I created a unit test or vtest to verify the changes I made (if applicable)

@krasko78 krasko78 marked this pull request as draft February 22, 2025 00:10
@cbjeukendrup
Copy link
Contributor

Good research! By your explanation, I'm convinced that disabling the MouseAreas was indeed not the best idea, so I'd be okay with reverting that and solving #25697 differently. I also don't really see an alternative way.

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.

Undo, Redo buttons don't clear hovered state after clicking with mouse
2 participants