MultiPointTouchArea QML 类型

Enables handling of multiple touch points. 更多...

import 语句: import QtQuick 2.2
继承: Item

特性

信号

详细描述

A MultiPointTouchArea is an invisible item that is used to track multiple touch points.

Item::enabled property is used to enable and disable touch handling. When disabled, the touch area becomes transparent to mouse and touch events.

By default, the mouse will be handled the same way as a single touch point, and items under the touch area will not receive mouse events because the touch area is handling them. But if the mouseEnabled property is set to false, it becomes transparent to mouse events so that another mouse-sensitive Item (such as a MouseArea ) can be used to handle mouse interaction separately.

MultiPointTouchArea can be used in two ways:

  • 设置 touchPoints to provide touch point objects with properties that can be bound to
  • using the onTouchUpdated or onPressed, onUpdated and onReleased handlers

While a MultiPointTouchArea can take exclusive ownership of certain touch points, it is also possible to have multiple MultiPointTouchAreas active at the same time, each operating on a different set of touch points.

另请参阅 TouchPoint .

特性文档编制

maximumTouchPoints : int
minimumTouchPoints : int

These properties hold the range of touch points to be handled by the touch area.

These are convenience that allow you to, for example, have nested MultiPointTouchAreas, one handling two finger touches, and another handling three finger touches.

By default, all touch points within the touch area are handled.

mouseEnabled is true, the mouse acts as a touch point, so it is also subject to these constraints: for example if maximumTouchPoints is two, you can use the mouse as one touch point and a finger as another touch point for a total of two.

mouseEnabled : bool

This property controls whether the MultiPointTouchArea will handle mouse events too. If it is true (the default), the touch area will treat the mouse the same as a single touch point; if it is false, the touch area will ignore mouse events and allow them to "pass through" so that they can be handled by other items underneath.

touchPoints : list < TouchPoint >

This property holds a set of user-defined touch point objects that can be bound to.

mouseEnabled is true (the default) and the left mouse button is pressed while the mouse is over the touch area, the current mouse position will be one of these touch points.

In the following example, we have two small rectangles that follow our touch points.

import QtQuick 2.0
Rectangle {
    width: 400; height: 400
    MultiPointTouchArea {
        anchors.fill: parent
        touchPoints: [
            TouchPoint { id: point1 },
            TouchPoint { id: point2 }
        ]
    }
    Rectangle {
        width: 30; height: 30
        color: "green"
        x: point1.x
        y: point1.y
    }
    Rectangle {
        width: 30; height: 30
        color: "yellow"
        x: point2.x
        y: point2.y
    }
}
					

By default this property holds an empty list.

另请参阅 TouchPoint .


信号文档编制

canceled ( list < TouchPoint > touchPoints )

This signal is emitted when new touch events have been canceled because another item stole the touch event handling.

This signal is for advanced use: it is useful when there is more than one MultiPointTouchArea that is handling input, or when there is a MultiPointTouchArea Flickable . In the latter case, if you execute some logic in the onPressed signal handler and then start dragging, the Flickable may steal the touch handling from the MultiPointTouchArea . In these cases, to reset the logic when the MultiPointTouchArea has lost the touch handling to the Flickable , canceled should be handled in addition to released .

touchPoints is the list of canceled points.

注意: 相应处理程序是 onCanceled .

gestureStarted ( GestureEvent gesture )

This signal is emitted when the global drag threshold has been reached.

This signal is typically used when a MultiPointTouchArea has been nested in a Flickable or another MultiPointTouchArea . When the threshold has been reached and the signal is handled, you can determine whether or not the touch area should grab the current touch points. By default they will not be grabbed; to grab them call gesture.grab() . If the gesture is not grabbed, the nesting Flickable, for example, would also have an opportunity to grab.

gesture object also includes information on the current set of touchPoints dragThreshold .

注意: 相应处理程序是 onGestureStarted .

pressed ( list < TouchPoint > touchPoints )

This signal is emitted when new touch points are added. touchPoints is a list of these new points.

minimumTouchPoints is set to a value greater than one, this signal will not be emitted until the minimum number of required touch points has been reached.

注意: 相应处理程序是 onPressed .

released ( list < TouchPoint > touchPoints )

This signal is emitted when existing touch points are removed. touchPoints is a list of these removed points.

注意: 相应处理程序是 onReleased .

touchUpdated ( list < TouchPoint > touchPoints )

This signal is emitted when the touch points handled by the MultiPointTouchArea change. This includes adding new touch points, removing or canceling previous touch points, as well as updating current touch point data. touchPoints is the list of all current touch points.

注意: 相应处理程序是 onTouchUpdated .

updated ( list < TouchPoint > touchPoints )

This signal is emitted when existing touch points are updated. touchPoints is a list of these updated points.

注意: 相应处理程序是 onUpdated .