26645: Fixed Undo/Redo buttons' hover state when disabled #26671
+7
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves: #26645
Key points:
&& root.enabled
to the condition for the "HOVERED" state.enabled: root.enabled
from theMouseArea
since it has side effects. See below.&& 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 particularcontainsMouse
of theMouseArea
remainstrue
. 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 betrue
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'sMouseArea
continues to betrue
since both the button and theMouseArea
are now disabled and theMouseArea
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 itsMouseArea
. 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 checkingroot.Enabled
where necessary.Curious fact: I discovered that the
MouseArea
has avisible
property which acts similarly to theenabled
property, i.e. if theMouseArea
is not visible, it effectively becomes disabled. I testedvisible: root.enabled
on theMouseArea
and interestingly found it to work pretty well, likeenabled: root.enabled
but without the above-mentioned side effects withcontainsMouse
(containsMouse
becamefalse
as soon as theMouseArea
was hidden). However, usingvisible
of a MouseArea is a non-standard approach. And who knows what hidden side effects on its own it has. :)