diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml index 874546f25ee131734a566023db08d0e38edd010f..cf12ed01bc8a3a5a7780c04ab89e6d6c3edd2553 100644 --- a/src/controls/TableView.qml +++ b/src/controls/TableView.qml @@ -311,6 +311,7 @@ ScrollView { var x = Math.min(flickableItem.contentWidth - 5, Math.max(mouseX + flickableItem.contentX, 0)) var y = Math.min(flickableItem.contentHeight - 5, Math.max(mouseY + flickableItem.contentY, 0)) listView.currentIndex = listView.indexAt(x, y) + mouse.accepted = false } onDoubleClicked: { root.activated() } diff --git a/tests/auto/controls/data/tableview/table_delegate.qml b/tests/auto/controls/data/tableview/table_delegate.qml new file mode 100644 index 0000000000000000000000000000000000000000..38f4c1ce41717b4ab495cccdd8de6640c120985a --- /dev/null +++ b/tests/auto/controls/data/tableview/table_delegate.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Quick Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.1 +import QtQuick.Controls 1.0 + +TableView { + id: table + model: [{"text": "text1"}, {"text": "text2"}, {"text": "text3"}] + property var test: 0 + + TableViewColumn { + title: "Text" + role: "text" + width: 100 + } + headerDelegate: Text { + height: 40 + text: itemValue + } + itemDelegate: Text { + width: parent.width + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + text: itemValue !== undefined ? itemValue : "" + color: itemTextColor + MouseArea { + anchors.fill: parent + onClicked: table.test = 1 + } + } +} + diff --git a/tests/auto/controls/data/tst_tableview.qml b/tests/auto/controls/data/tst_tableview.qml index cd83ef3d68c4c807e22e97b97e00b3f63c5fa371..4bdf15dbcc9b72b62974022e2cf21263d418eee3 100644 --- a/tests/auto/controls/data/tst_tableview.qml +++ b/tests/auto/controls/data/tst_tableview.qml @@ -43,6 +43,11 @@ import QtTest 1.0 import QtQuick.Controls 1.0 import QtQuickControlsTests 1.0 +Item { + id: container + width: 400 + height: 400 + TestCase { id: testCase name: "Tests_TableView" @@ -140,6 +145,18 @@ TestCase { table.destroy(); } + function test_forwardClickToChild() { + var component = Qt.createComponent("tableview/table_delegate.qml") + compare(component.status, Component.Ready) + var table = component.createObject(container); + verify(table !== null, "table created is null") + table.forceActiveFocus(); + compare(table.test, 0) + mouseClick(table, 15 , 55, Qt.LeftButton) + compare(table.test, 1) + table.destroy() + } + // In TableView, drawn text = table.currentRowItem.children[1].children[1].itemAt(0).children[0].children[0].text function findAChild(item, name) @@ -171,3 +188,4 @@ TestCase { return undefined // no matching child found } } +}