QtMobility Reference Documentation

QML MapMouseArea Element

The MapMouseArea item enables simple mouse handling. More...

This element was introduced in Mobility 1.2.

Properties

Signal Handlers

Detailed Description

A MapMouseArea is an invisible item that is typically used in conjunction with a visible map object or map item in order to provide mouse handling. By effectively acting as a proxy, the logic for mouse handling can be contained within a MapMouseArea item.

The enabled property is used to enable and disable mouse handling for the proxied item. When disabled, the mouse area becomes transparent to mouse events.

The pressed read-only property indicates whether or not the user is holding down a mouse button over the mouse area. This property is often used in bindings between properties in a user interface.

Information about the mouse position and button clicks are provided via signals for which event handler properties are defined. The most commonly used involved handling mouse presses and clicks: onClicked, onDoubleClicked, onPressed and onReleased.

MapMouseArea items only report mouse clicks and not changes to the position of the mouse cursor.

See also MapMouseEvent.

Property Documentation

acceptedButtons : Qt::MouseButtons

This property holds the mouse buttons that the mouse area reacts to.

The available buttons are:

  • Qt.LeftButton
  • Qt.RightButton
  • Qt.MiddleButton

To accept more than one button the flags can be combined with the "|" (or) operator:

 MapMouseArea { acceptedButtons: Qt.LeftButton | Qt.RightButton }

The default value is Qt.LeftButton.

This property group was introduced in Mobility 1.2.


enabled : bool

This property holds whether the item accepts mouse events.

By default, this property is true.

This property group was introduced in Mobility 1.2.


read-onlymouseX : qreal

read-onlymouseY : qreal

These properties hold the screen coordinates of the mouse cursor.

These properties will only be valid while a button is pressed, and will remain valid as long as the button is held down even if the mouse is moved outside the area.

The screen coordinates are relative to the MouseArea.

This property group was introduced in Mobility 1.2.


read-onlypressed : bool

This property holds whether the mouse area is currently pressed.

This property group was introduced in Mobility 1.2.


read-onlypressedButton : MouseButton

This property holds the mouse button currently pressed.

It is one of:

  • Qt.LeftButton
  • Qt.RightButton
  • Qt.MiddleButton

This property group was introduced in Mobility 1.2.

See also acceptedButtons.


Signal Handler Documentation

MapMouseArea::onClicked ( MapMouseEvent mouse )

This handler is called when there is a click. A click is defined as a press followed by a release, both inside the MapMouseArea (pressing, moving outside the MapMouseArea, and then moving back inside and releasing is also considered a click).

The mouse parameter provides information about the click, including the x and y position of the release of the click.

The accepted property of the MapMouseEvent parameter is ignored in this handler.

This documentation was introduced in Mobility 1.2.


MapMouseArea::onDoubleClicked ( MapMouseEvent mouse )

This handler is called when there is a double-click (a press followed by a release followed by a press).

The mouse parameter provides information about the click, including the x and y position of the release of the click.

If the accepted property of the mouse parameter is set to false in the handler, the onPressed/onReleased/onClicked handlers will be called for the second click; otherwise they are suppressed. The accepted property defaults to true.

This documentation was introduced in Mobility 1.2.


MapMouseArea::onPressed ( MapMouseEvent mouse )

This handler is called when there is a press.

The mouse parameter provides information about the press, including the x and y position and which button was pressed.

The accepted property of the MapMouseEvent parameter determines whether this MapMouseArea will handle the press and all future mouse events until release. The default is to accept the event and not allow other MapMouseArea beneath this one to handle the event. If accepted is set to false, no further events will be sent to this MapMouseArea until the button is next pressed.

This documentation was introduced in Mobility 1.2.


MapMouseArea::onReleased ( MapMouseEvent mouse )

This handler is called when there is a release. The mouse parameter provides information about the click, including the x and y position of the release of the click.

The accepted property of the MapMouseEvent parameter is ignored in this handler.

This documentation was introduced in Mobility 1.2.


X

Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.