【发布时间】:2019-02-23 20:08:06
【问题描述】:
我目前通过 QML 中的 MouseArea 接收鼠标事件。我可以区分鼠标左键、右键和中键。在 Mac 上,按住 Control 和 Left Clicking 被解释为 Qt.RightButton 按下。无论如何要区分标准的右键单击和(Ctrl + 左)右键单击吗?我需要这样做来处理自定义 UI 交互(我知道这是一种反模式)。
注意:特别是,我需要区分 Ctrl + 左键单击和 Ctrl + 右键单击。因此,仅检测在接收到右键单击事件时按下 Control 是不够的。
function button( mouse )
{
if( mouse.button == Qt.LeftButton )
{
console.log("left button is pressed");
return 0;
} else if( mouse.button == Qt.MidButton )
{
console.log("mid button");
return 1;
} else if ( mouse.button == Qt.RightButton )
{
console.log("right button pressed");
}
}
【问题讨论】:
-
我不太喜欢 QML,但我想你应该只寻找修饰符:doc.qt.io/qt-5/qml-qtquick-mouseevent.html#modifiers-prop