oblitum
oblitum

Reputation: 12016

MouseArea inside Flickable/TextEdit doesn't pass through mouse events using propagateComposedEvents

import QtQuick 2.2
import QtQuick.Window 2.1
import QtQuick.Controls 1.1

ApplicationWindow {
    flags: Qt.FramelessWindowHint
    width: 500
    height: 500
    x: (Screen.width - width) / 2
    y: (Screen.height - height) / 2
    color: "black"
    opacity: 0.8

    Flickable {
        anchors.fill: parent
        contentWidth: html.paintedWidth
        contentHeight: html.paintedHeight
        boundsBehavior: Flickable.StopAtBounds
        TextEdit {
            id: html
            objectName: "html"
            anchors.fill: parent
            textFormat: TextEdit.RichText
            focus: true
            Keys.onEscapePressed: Qt.quit()
            font.family: "Droid Sans Mono"
            font.pointSize: 11
            selectByMouse: true
            readOnly: true
            MouseArea {
                anchors.fill: parent
                propagateComposedEvents: true
                onClicked: {
                    console.log("clicked")
                    mouse.accepted = false
                }
            }
        }
    }
}

I'm unable to get "clicked" printed... it seems like propagateComposedEvents and mouse.accepted are just not working as expected.

I'm using Qt 5.3 Beta.

Upvotes: 4

Views: 1288

Answers (1)

jkj yuio
jkj yuio

Reputation: 2613

contentWidth/Height is wrong,

import QtQuick 2.2
import QtQuick.Window 2.1
import QtQuick.Controls 1.1

ApplicationWindow {
    flags: Qt.FramelessWindowHint
    width: 500
    height: 500
    x: (Screen.width - width) / 2
    y: (Screen.height - height) / 2
    //color: "black"
    opacity: 0.8
    visible: true

    Flickable {
        anchors.fill: parent
        //contentWidth: html.paintedWidth
        //contentHeight: html.paintedHeight
        boundsBehavior: Flickable.StopAtBounds
        TextEdit {
            id: html
            objectName: "html"
            anchors.fill: parent
            textFormat: TextEdit.RichText
            focus: true
            Keys.onEscapePressed: Qt.quit()
            font.family: "Droid Sans Mono"
            font.pointSize: 11
            selectByMouse: true
            readOnly: true
            text: "hello world"
            MouseArea {
                anchors.fill: parent
                propagateComposedEvents: true
                onClicked: {
                    console.log("clicked")
                    mouse.accepted = false
                }
            }
        }
    }
}

Upvotes: 1

Related Questions