Skip to content

Commit

Permalink
26665: Toolbar buttons do not react to long clicks
Browse files Browse the repository at this point in the history
  • Loading branch information
krasko78 committed Feb 22, 2025
1 parent 6895d79 commit 9a3e528
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
11 changes: 9 additions & 2 deletions src/framework/uicomponents/qml/Muse/UiComponents/FlatButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ FocusScope {
}

signal clicked(var mouse)
// There are intentionally no "forwarded" signals here from the MouseArea, like `pressAndHold`
// See https://github.com/musescore/MuseScore/issues/16012#issuecomment-1399656043
signal pressAndHold(var mouseEvent)

objectName: root.text

Expand Down Expand Up @@ -313,6 +312,14 @@ FocusScope {
ui.tooltip.hide(root, true)
}

onPressAndHold: function(mouseEvent) {
// Set 'accepted' to false (it is true by default) to not supress the click event.
// If a handler consumes this event, it should set 'accepted' to true.
mouseEvent.accepted = false

root.pressAndHold(mouseEvent)
}

onContainsMouseChanged: {
if (!Boolean(root.toolTipTitle) || root.toolTipShowLocked) {
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,15 @@ FlatButton {
}
}

Connections {
target: root.mouseArea

enabled: root.hasMenu && !menuLoader.isMenuOpened
onPressAndHold: function(mouseEvent) {
if (menuLoader.isMenuOpened || !root.hasMenu) {
return
}

function onPressAndHold() {
if (menuLoader.isMenuOpened || !root.hasMenu) {
return
}
// consume event and suppress the click event
mouseEvent.accepted = true

root.toggleMenuOpened()
}
root.toggleMenuOpened()
}

Canvas {
Expand Down
19 changes: 7 additions & 12 deletions src/notation/qml/MuseScore/NotationScene/NoteInputBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -155,20 +155,15 @@ Item {
}
}

Connections {
target: btn.mouseArea

// Make sure we only connect to `pressAndHold` if necessary
// See https://github.com/musescore/MuseScore/issues/16012
enabled: btn.hasMenu && !menuLoader.isMenuOpened
onPressAndHold: function(mouseEvent) {
if (menuLoader.isMenuOpened || !btn.hasMenu) {
return
}

function onPressAndHold() {
if (menuLoader.isMenuOpened || !btn.hasMenu) {
return
}
// consume event and suppress the click event
mouseEvent.accepted = true

btn.toggleMenuOpened()
}
btn.toggleMenuOpened()
}

StyledMenuLoader {
Expand Down

0 comments on commit 9a3e528

Please sign in to comment.