There you go. I slightly modified the "content/FlickableWebView.qml" to show
what's going on with the focus:
import Qt 4.7
import org.webkit 1.0
Flickable {
property alias title: webView.title
property alias icon: webView.icon
property alias progress: webView.progress
property alias url: webView.url
property alias back: webView.back
property alias reload: webView.reload
property alias forward: webView.forward
id: flickable
width: parent.width
contentWidth: Math.max(parent.width,webView.width)
contentHeight: Math.max(parent.height,webView.height)
anchors.top: headerSpace.bottom
anchors.bottom: parent.top
anchors.left: parent.left
anchors.right: parent.right
pressDelay: 200
onWidthChanged : {
// Expand (but not above 1:1) if otherwise would be smaller that
available width.
if (width > webView.width*webView.contentsScale &&
webView.contentsScale < 1.0)
webView.contentsScale = width / webView.width *
webView.contentsScale;
}
*onFocusChanged: {*
* if ( focus == true ) {*
* console.log("Flickable got focus");*
* }*
* else {*
* console.log("Flickable lost focus");*
* }*
* }*
WebView {
id: webView
transformOrigin: Item.TopLeft
function fixUrl(url)
{
if (url == "") return url
if (url[0] == "/") return "file://"+url
if (url.indexOf(":")<0) {
if (url.indexOf(".")<0 || url.indexOf(" ")>=0) {
// Fall back to a search engine; hard-code Wikipedia
return "http://en.wikipedia.org/w/index.php?search="+url
} else {
return "http://"+url
}
}
return url
}
url: fixUrl(webBrowser.urlString)
smooth: false // We don't want smooth scaling, since we only scale
during (fast) transitions
focus: true
zoomFactor: 1
onAlert: console.log(message)
function doZoom(zoom,centerX,centerY)
{
if (centerX) {
var sc = zoom/contentsScale;
scaleAnim.to = zoom;
flickVX.from = flickable.contentX
flickVX.to =
Math.max(0,Math.min(centerX-flickable.width/2,webView.width*sc-flickable.width))
finalX.value = flickVX.to
flickVY.from = flickable.contentY
flickVY.to =
Math.max(0,Math.min(centerY-flickable.height/2,webView.height*sc-flickable.height))
finalY.value = flickVY.to
quickZoom.start()
}
}
Keys.onLeftPressed: webView.contentsScale -= 0.1
Keys.onRightPressed: webView.contentsScale += 0.1
preferredWidth: flickable.width
preferredHeight: flickable.height
contentsScale: 1/zoomFactor
onContentsSizeChanged: {
// zoom out
contentsScale = Math.min(1,flickable.width / contentsSize.width)
}
onUrlChanged: {
// got to topleft
flickable.contentX = 0
flickable.contentY = 0
if (url != null) { header.editUrl = url.toString(); }
}
onDoubleClick: {
if (!heuristicZoom(clickX,clickY,2.5)) {
var zf = flickable.width / contentsSize.width
if (zf >= contentsScale)
zf = 2.0/zoomFactor // zoom in (else zooming out)
doZoom(zf,clickX*zf,clickY*zf)
}
}
*onFocusChanged: {*
* if ( focus == true ) {*
* console.log("WebView got focus");*
* }*
* else {*
* console.log("WebView lost focus");*
* }*
* }*
SequentialAnimation {
id: quickZoom
PropertyAction {
target: webView
property: "renderingEnabled"
value: false
}
ParallelAnimation {
NumberAnimation {
id: scaleAnim
target: webView
property: "contentsScale"
// the to property is set before calling
easing.type: Easing.Linear
duration: 200
}
NumberAnimation {
id: flickVX
target: flickable
property: "contentX"
easing.type: Easing.Linear
duration: 200
from: 0 // set before calling
to: 0 // set before calling
}
NumberAnimation {
id: flickVY
target: flickable
property: "contentY"
easing.type: Easing.Linear
duration: 200
from: 0 // set before calling
to: 0 // set before calling
}
}
// Have to set the contentXY, since the above 2
// size changes may have started a correction if
// contentsScale < 1.0.
PropertyAction {
id: finalX
target: flickable
property: "contentX"
value: 0 // set before calling
}
PropertyAction {
id: finalY
target: flickable
property: "contentY"
value: 0 // set before calling
}
PropertyAction {
target: webView
property: "renderingEnabled"
value: true
}
}
onZoomTo: doZoom(zoom,centerX,centerY)
}
}
While on the desktop the Focus works as expected, on N900 the WebView gets
the focus while clicked/pressed, and releases it on unclicked/released.
I was getting weird behaviours because I connected to the WebView.focus
property to do some graphics effect, but now everything seems a bit "crazy".
This to me starts to look like a real bug *OR* the N900 4.7 branch just
needs to be put in sync with the current 4.7.
On 2 June 2010 17:00, Ivan De Marino <[email protected]> wrote:
> I figured out what was stopping the "scrolling" but this unveiled that
> there is something else going on.
> What I was doing to "stop" the scrolling was:
>
> interactive: webView.focus // If the "webView" has focus, then it's
> flickable
>
> In this way there is no scrolling if the WebView that is inside the
> Flickable element doesn't have focus.
>
> Looks like there is an impediment at the WebView from getting a proper
> focus.
> I removed the above line, and what happens as soon as I start
> scrolling/panning, is that the WebView looses focus.
>
> On 2 June 2010 12:30, Ivan De Marino <[email protected]> wrote:
>
>>
>>
>> On 2 June 2010 12:22, Alan Alpert <[email protected]> wrote:
>>
>>>
>>> Onsdag 2. juni 2010 21:01:55 skrev ext Ivan De Marino :
>>>
>>> > Problem is that I'm a bit stuck now: the latest version of my project
>>> works
>>> > without any problem (aside from the bugs I didn't discover yet :P),
>>> while
>>> > on N900 the behaviour is always a bit "flaky". With realease 2010-05-20
>>> of
>>> > the packages of "libqt4-experimental" for N900 1.2, I now lost
>>> > SCROLLING/PANNING And I can't make my head around on what is the actual
>>> > problem. I just use a Flickable element with a WebView inside: don't
>>> see
>>> > what can go wrong, and only on N900. The QML part of my project here:
>>> >
>>> http://github.com/OrangeLabsUK/OrangeMobileBrowser/tree/master/orangemobil
>>> > ebrowser-1.0/src/qmls/ .
>>>
>>> The webbrowser demo is working just fine on my n900. You might want to
>>> have a
>>> look at the differences between your FlickableWebView and the one in
>>> demos/declarative/webbrowser. This demo has had a bunch of minor changes
>>> recently, so you should have another look even if you've seen it before.
>>>
>>> I don't think any of those changes relate to this specific problem, but I
>>> could
>>> be wrong. And the recent webbrowser demo pans just fine on my N900 with
>>> those
>>> packages installed.
>>>
>> That's what I just tested and seen. I'm now trying to figure out what are
>> the macro differences on how things are laid out.
>> I was thinking that could be the "focusAway" black rectangle I apply on
>> the WebView when it looses focus.
>> The Z axis maybe.
>>
>> Will check and report.
>>
>>
>>>
>>> >
>>> > Plus, I can't use OpenGL in my GraphicsView because... no idea! It's
>>> slow,
>>> > painfully slow. I get much better performance if I "#ifdef" it out.
>>>
>>> With the PR1.2 packages this is a known issue, and is caused by a bug
>>> involving clipping. The next set of Qt 4.7 packages should hopefully
>>> resolve
>>> it. Until then keep trying without using OpenGL.
>>>
>> Great! This means I'm not doing something wrong myself.
>> I'll wait for the new packages ;)
>>
>> Thanks a lot.
>>
>>>
>>> --
>>>
>>> Alan Alpert
>>> Software Engineer
>>> Nokia, Qt Development Frameworks
>>> _______________________________________________
>>> Qt-qml mailing list
>>> [email protected]
>>> http://lists.trolltech.com/mailman/listinfo/qt-qml
>>>
>>
>>
>>
>> --
>> Ivan De Marino | Software Engineer | France Telecom R&D UK - Orange Labs
>> w. +44 20 8849 5806 | m. +44 7515 955 861 | m. +44 7974 156 216
>> ivan[dot]demarino[at]orange-ftgroup.com |
>> ivan[dot]de[dot]marino[at]gmail[dot]com
>> www.detronizator.org | www.linkedin.com/in/ivandemarino
>>
>
>
>
> --
> Ivan De Marino | Software Engineer | France Telecom R&D UK - Orange Labs
> w. +44 20 8849 5806 | m. +44 7515 955 861 | m. +44 7974 156 216
> ivan[dot]demarino[at]orange-ftgroup.com |
> ivan[dot]de[dot]marino[at]gmail[dot]com
> www.detronizator.org | www.linkedin.com/in/ivandemarino
>
--
Ivan De Marino | Software Engineer | France Telecom R&D UK - Orange Labs
w. +44 20 8849 5806 | m. +44 7515 955 861 | m. +44 7974 156 216
ivan[dot]demarino[at]orange-ftgroup.com |
ivan[dot]de[dot]marino[at]gmail[dot]com
www.detronizator.org | www.linkedin.com/in/ivandemarino
_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-qml