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

26665: Toolbar buttons do not react to long clicks #26679

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading