Skip to content

Commit

Permalink
Merge pull request #24881 from cbjeukendrup/qt_next/hover_no_longer_p…
Browse files Browse the repository at this point in the history
…ropagated_to_siblings

Work around Qt 6.2.5+ rich text hover bug
  • Loading branch information
cbjeukendrup committed Sep 24, 2024
2 parents f14d5ec + 8e40288 commit d36cf71
Showing 1 changed file with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,22 @@ ListItemBlank {
return text
}

// https://github.com/musescore/MuseScore/pull/24644#issuecomment-2356235871
// Since https://github.com/qt/qtdeclarative/commit/499828b855d125ac236917f6ed01d8f1e7d88505
// (cherry-picked to Qt 6.2.5 as https://github.com/qt/qtdeclarative/commit/caf81fefbe3f5b8e2fb7892b40b4748db3230046)
// hover events are not propagated anymore between siblings, only to ancestors.
// For us, that means that they are not propagated anymore from the StyledTextLabel
// with `textFormat: Text.RichText` (which accepts hover events) to the MouseArea,
// which is not an ancestor of the StyledTextLabel.
// The fact that the StyledTextLabel accepts hover events cannot be changed from
// QML (there is no way to call `QQuickItem::setAcceptHoverEvents(false)`).
// Making the MouseArea an ancestor of the StyledTextLabel is not possible either,
// because the MouseArea is defined far away in FocusableControl (from which
// ListItemBlank inherits).
// As a workaround, we ensure that the MouseArea is on top of the StyledTextLabel,
// so that it takes precedence.
mouseArea.z: 1000

QtObject {
id: itemPrv

Expand Down Expand Up @@ -198,11 +214,6 @@ ListItemBlank {
text: itemPrv.titleWithMnemonicUnderline

textFormat: Text.RichText
//! If the rich text format is set, then the component intercepts the hover state
// The hover state is required to open a submenu(see onHovered)
// So, let's turn off the mouse hovering over the component
enabled: false
opacity: root.enabled ? 1.0 : ui.theme.itemOpacityDisabled
}

StyledTextLabel {
Expand Down

0 comments on commit d36cf71

Please sign in to comment.