Warning, /frameworks/kdeclarative/tests/mouseeventlistenertest.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2014 David Edmundson <davidedmundson@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 import org.kde.qtextracomponents 2.0
0008 import QtQuick 2.1
0009 import QtQuick.Layouts 1.0
0010 
0011 
0012 Item
0013 {
0014     width: 800
0015     height: 400
0016     Row {
0017         anchors.fill: parent
0018         MouseEventListener {
0019             width: 400
0020             height: 400
0021             id: mouseListener
0022             acceptedButtons: Qt.LeftButton
0023             hoverEnabled: true
0024             onPressed: {
0025                 updateDebug("Pressed", mouse);
0026             }
0027             onPressAndHold: {
0028                 updateDebug("Held", mouse);
0029             }
0030             onReleased: {
0031                 mouseState.text = "";
0032                 mousePos.text = "";
0033                 screenPos.text = "";
0034             }
0035 
0036             function updateDebug(state, mouse) {
0037                 mouseState.text = state
0038                 mousePos.text = mouse.x + "," + mouse.y
0039                 screenPos.text = mouse.screenX + "," + mouse.screenY
0040             }
0041 
0042             Rectangle {
0043                 color: "red"
0044                 anchors.fill: parent
0045 
0046                 //MouseEventListener should still get events, even though this has a mousearea
0047                 MouseArea {
0048                     anchors.fill: parent
0049                 }
0050             }
0051         }
0052 
0053         GridLayout {
0054             width: 400
0055             columns: 2
0056             Text {
0057                 text: "Mouse status:"
0058             }
0059             Text {
0060                 id: mouseState
0061             }
0062             Text {
0063                 text: "Contains Mouse: "
0064             }
0065             Text {
0066                 text: mouseListener.containsMouse
0067             }
0068             Text {
0069                 text: "Mouse Position: "
0070             }
0071             Text {
0072                 id: mousePos
0073             }
0074             Text {
0075                 text: "Screen Position: "
0076             }
0077             Text {
0078                 id: screenPos
0079             }
0080         }
0081     }
0082 }