Unsolved MouseArea hover and TextFormat RichText/StyledText seems incompatible
-
Hi,
I've found that when using a Text Component considered (or forced) as either StyledText or RichText prevents the hover area from existing on top of the Text Area. I'm not sure if this is a bug or an intended behavior that I don't get the reason.Here is an example :
/* Just a simple rectangle with a simple text and * whose background color is changed when hovered */ import QtQuick 2.0 Rectangle { id: root width: 1000 height: 1000 color: "#FFFFFF" MouseArea { anchors.fill: parent hoverEnabled: true onEntered: { console.log("entered"); root.color = "#F0F0F0"; } onExited: { console.log("exited"); root.color = "#FFFFFF"; } } Text { width: implicitWidth height: implicitHeight // Here is where is the problem // (fails with StyledText and RichText) textFormat: Text.StyledText text: "blablabla" } }
The same example that now works fine :
/* Just a simple rectangle with a simple text and * whose background color is changed when hovered */ import QtQuick 2.0 Rectangle { id: root width: 1000 height: 1000 color: "#FFFFFF" MouseArea { anchors.fill: parent hoverEnabled: true onEntered: { console.log("entered"); root.color = "#FF0000"; } onExited: { console.log("exited"); root.color = "#FFFFFF"; } } Text { width: implicitWidth height: implicitHeight // The hovering works fine with PlainText textFormat: Text.PlainText text: "blablabla" } }
You should see that in the first example, the exited signal is triggered when the mouse is over the Text (so background changes color and log is printed) whereas it doesn't happen in the second example.
Is anyone having the same behavior ? Does anyone knows if I should report it as a bug or is it intended ?
--
QtVersion : 5.7 and 5.9 at least