Skip to content

Commit 313b5a0

Browse files
committed
fix: disable context menu on right-click
1. Prevent default context menu from appearing on right-click by consuming the event in onPressed 2. Disable launcher toggle on touch screen long-press by introducing a longPressed flag 3. Explicitly define acceptedButtons for left and right mouse buttons Log: Disabled right-click and long-press context menus on launcher items Influence: 1. Verify right-clicking a launcher item does not open a context menu 2. Verify long-pressing on a touchscreen does not trigger the launcher toggle 3. Verify normal left-click still toggles the launcher correctly fix: 禁用右键和长按菜单 1. 通过在 onPressed 中消费事件,阻止鼠标右键点击时弹出默认上下文菜单 2. 引入 longPressed 标志位,禁用触控屏长按触发启动器切换的功能 3. 显式定义左键和右键的 acceptedButtons Log: 禁用启动器项上的右键和长按上下文菜单 Influence: 1. 验证鼠标右键点击启动器项不再弹出上下文菜单 2. 验证触控屏长按不再触发启动器切换 3. 验证普通鼠标左键点击仍能正常切换启动器 PMS: BUG-358827 Change-Id: I598c0c4a453ba63df5a3adf74df5260ba6bcf5a6
1 parent 1abad99 commit 313b5a0

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

shell-launcher-applet/package/launcheritem.qml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,19 @@ AppletItem {
384384
MouseArea {
385385
id: mouseHandler
386386
anchors.fill: parent
387+
acceptedButtons: Qt.LeftButton | Qt.RightButton
388+
property bool longPressed: false
389+
onPressed: function (mouse) {
390+
longPressed = false
391+
if (mouse.button === Qt.RightButton) {
392+
mouse.accepted = true
393+
}
394+
}
395+
onPressAndHold: function (mouse) {
396+
longPressed = true
397+
}
387398
onClicked: function (mouse) {
388-
if (mouse.button === Qt.LeftButton) {
399+
if (mouse.button === Qt.LeftButton && !longPressed) {
389400
toggleLauncher()
390401
}
391402
}

0 commit comments

Comments
 (0)