Commit 7cdef75f authored by eekkelund's avatar eekkelund

Add new component: InverseMouseArea.qml

parent 3858cd52
......@@ -12,4 +12,5 @@ documentation.list
examples/touch/glacier-components
Makefile
installroot/
RPMS/
\ No newline at end of file
RPMS/
debug*.list
This diff is collapsed.
/**
Author : Ben Lau (@benlau)
License: Apache
*/
import QtQuick 2.6
Item {
id : component
property Item sensingArea : null
signal pressed
property var _mouseArea : null
function _setupMouseArea() {
if (!_mouseArea) {
_mouseArea = mouseAreaBuilder.createObject(component);
}
var p = sensingArea;
if (!p)
p = _topMostItem();
_mouseArea.parent = p;
}
function _destroyMouseArea() {
if (_mouseArea) {
_mouseArea.destroy();
_mouseArea = null;
}
}
function _inBound(pt) {
var ret = false;
if (pt.x >= component.x &&
pt.y >= component.y &&
pt.x <= component.x + component.width &&
pt.y <= component.y + component.height) {
ret = true;
}
return ret;
}
function _topMostItem() {
var p = component;
while (p.parent) {
p = p.parent;
}
return p;
}
Component {
id : mouseAreaBuilder
MouseArea {
propagateComposedEvents : true
anchors.fill: parent
z: 200000000
onPressed: {
mouse.accepted = false;
var pt = mapToItem(component.parent,mouse.x,mouse.y)
if (!_inBound(pt))
component.pressed();
}
}
}
onEnabledChanged: {
_destroyMouseArea();
if (enabled) {
_setupMouseArea();
}
}
Component.onCompleted: {
if (enabled)
_setupMouseArea();
}
Component.onDestruction: {
_destroyMouseArea();
}
}
......@@ -21,7 +21,8 @@ QML_FILES += \
ListView.qml \
ListViewItemWithActions.qml\
GlacierRoller.qml \
GlacierRollerItem.qml
GlacierRollerItem.qml \
InverseMouseArea.qml
OTHER_FILES += qmldir \
$$QML_FILES
......
......@@ -23,6 +23,7 @@ ListView 1.0 ListView.qml
ListViewItemWithActions 1.0 ListViewItemWithActions.qml
GlacierRoller 1.0 GlacierRoller.qml
GlacierRollerItem 1.0 GlacierRollerItem.qml
InverseMouseArea 1.0 InverseMouseArea.qml
# MIRRORED CONTROLS:
# These are the controls that we take directly from official QQC.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment