We have moved to a new Sailfish OS Forum. Please start new discussions there.
3

Closing dialog with VKB active breaks canvas on returning page [answered]

asked 2014-06-06 10:34:54 +0200

kimmoli gravatar image

updated 2015-05-26 14:26:24 +0200

heubergen gravatar image

While implementing text overlay tool to Paint application noticed following annoyance (#bug)

I have a page with canvas, then i push to a Dialog with TextField to enter some text. When i accept the Dialog it returns nicely to the page, but if the VKB is open, canvas gets roughly 10 onPaint events. If VKB is hidden while closing dialog there are no such onPaint events.

And when next draw/stroke/path (in this case context.fillText()) is applied to the canvas, everything that was already drawn on canvas gets cleared. Sometimes random pixels appear too.

Maybe pageStack animation happening at same time as the VKB fadeout happens causes this (?)

As workaround, before allowing Dialog to be accepted, i set TextField.focus to false, wait 500ms for VKB to disappear, then call Dialog.accept().

(Have not tried PageStackAction.Immediate, or is it even possible to apply to Accept (or Cancel) dialog events?)

*VKB Virtual keyboard

edit retag flag offensive reopen delete

The question has been closed for the following reason "the question is answered, an answer was accepted" by kimmoli
close date 2015-05-26 15:23:24.297806

Comments

Seems that on latest OS version, 500 ms is not always enough, canvas still gets cleared, increased to 1000 ms.

kimmoli ( 2015-05-26 14:16:25 +0200 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2015-05-26 15:13:13 +0200

kimmoli gravatar image

Seems that when pageStack animation is going on, and VKB is sliding down, and it will effect height of page where canvas is (page where we are navigating back from dialog).

Canvas is anchored to fill this page, so it follows page height. And chaging canvas size will clear it.

[D] onPaint:37 - onPaint, canvas.width. 540 height: 522.6619873046875 pageStack.busy: true
[D] onPaint:37 - onPaint, canvas.width. 540 height: 537.2479858398438 pageStack.busy: true
[D] onPaint:37 - onPaint, canvas.width. 540 height: 566.552001953125 pageStack.busy: true
[D] onPaint:37 - onPaint, canvas.width. 540 height: 607.3179931640625 pageStack.busy: true
[D] onPaint:37 - onPaint, canvas.width. 540 height: 664.3419799804688 pageStack.busy: true
[D] onPaint:37 - onPaint, canvas.width. 540 height: 731.2880249023438 pageStack.busy: true
[D] onPaint:37 - onPaint, canvas.width. 540 height: 804.7680053710938 pageStack.busy: true
[D] onPaint:37 - onPaint, canvas.width. 540 height: 907.177978515625 pageStack.busy: true
[D] onPaint:37 - onPaint, canvas.width. 540 height: 956.83203125 pageStack.busy: true
[D] onPaint:37 - onPaint, canvas.width. 540 height: 960 pageStack.busy: true

Solution is to set canvas width/height explicitly, not anchor it to page. Replaced anchoring with below code to set them just once:

Component.onCompleted:
{
    width = parent.width
    height = parent.height
    requestPaint()
}
edit flag offensive delete publish link more

Question tools

Follow
1 follower

Stats

Asked: 2014-06-06 10:34:54 +0200

Seen: 183 times

Last updated: May 26 '15