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

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 displayed which is the current behavior although there are stories to re-enable tooltips for disabled elements).

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. In particular containsMouse of the MouseArea remains true. 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. As mentioned, 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, it is like frozen. 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 is we should not be disabling the MouseArea. Instead we should be checking root.Enabled where necessary.
Curious fact: I discovered that the MouseArea has a visible property which acts similarly to the enabled property, i.e. if the MouseArea is not visible, it effectively becomes disabled. I tested visible: root.enabled on the MouseArea and interestingly found it to work pretty well, like enabled: root.enabled but without the above-mentioned side effects with containsMouse (containsMouse became false as soon as the MouseArea was hidden). However, using visible of a MouseArea is a non-standard approach. And who knows what hidden side effects on its own it has. :)

  • 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
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
1 participant