On Wed, 18 Jul 2012 13:47:36 ext Nils Jeisecke wrote:
> Hi,
> 
> In QtQuick 1 an element with opacity == 0 is treated as invisible
> (e.g. it won't see mouse events).
> This has changed in QtQuick 2.0 which breaks existing code that
> assumes that opacity == 0 means !visible.
> 
> This example illustrates the change. A mouse click will print:
> QtQuick 1.1: "CLICKED A"
> QtQuick 2.0: "CLICKED B"
> 
> A workaround is to set "visible: opacity > 0"
> 
> Is this change intentional?

Yes, this was intentional. Opacity is now a purely visual property, and only 
visible is used for optimizations (such as not receiving input or being 
positioned). Sorry, this should have been listed in What's New; 
https://codereview.qt-project.org/31057 fixes this.

The reason, apart from better conceptual consistency, is that this makes 
opacity a lot easier to use and animate in some circumstances. Key edge cases 
involved wanting to fade something out but not actually lose the 'visible' 
behavior, such as collecting mouse events or being positioned by positioner 
elements. Previously the below snippet would have the green rectangle jerk 
around a lot because it was repositioned in the instant that opacity became 0 
for the blue rectangle, and again when it became non-zero.

Column {
        Rectangle { color: "red"; width: 40; height: 40}
        Rectangle 
        { 
                color: "blue"; width: 40; height: 40
                SequentialAnimation on opacity {
                        NumberAnimation{ from: 1; to: 0 }
                        NumberAnimation{ from: 0; to: 1 }
                }
        }
        Rectangle { color: "green"; width: 40; height: 40}
}

You can imagine the analagous situation with a MouseArea, where its subtree is 
pulsing in opacity and if the user clicks at the wrong time then it 
inexplicably doesn't work.

--
Alan Alpert
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to