PointerEvent QML Type

Provides information about an event from a pointing device. 更多...

import 语句: import QtQuick 2.15

特性

详细描述

A PointerEvent is an event describing contact or movement across a surface, provided by a mouse, a touchpoint (single finger on a touchscreen), or a stylus on a graphics tablet. The device property provides more information about where the event came from.

另请参阅 PointerHandler .

特性文档编制

[read-only] button : enumeration

此特性保持 button that caused the event, if any. If the device does not have buttons, or the event is a hover event, it will be Qt.NoButton .

[read-only] buttons : int

This property holds the combination of mouse or stylus buttons pressed when the event was generated. For move events, this is all buttons that are pressed down. For press events, this includes the button that caused the event, as well as any others that were already held. For release events, this excludes the button that caused the event.

[read-only] device : PointerDevice

This property holds the device that generated the event.

[read-only] modifiers : int

此特性保持 keyboard modifier flags that existed immediately before the event occurred.

It contains a bitwise combination of the following flags:

常量 描述
Qt.NoModifier 未按下修饰符键。
Qt.ShiftModifier 按下键盘 Shift 键。
Qt.ControlModifier 按下键盘 Ctrl 键。
Qt.AltModifier 按下键盘 Alt 键。
Qt.MetaModifier 按下键盘 Meta 键。
Qt.KeypadModifier 按下 Keypad (小键盘) 按钮。

For example, to react to a Shift key + Left mouse button click:

Item {
    TapHandler {
        onTapped: {
            if ((event.button == Qt.LeftButton) && (event.modifiers & Qt.ShiftModifier))
                doSomething();
        }
    }
}