Discussion:
[Wt-interest] How to animate filling in a WLineEdit?
K. Frank
2015-01-01 19:10:05 UTC
Permalink
Hello List!

What would be a good way -- the Wt way -- to animate filling
in a WLineEdit? What I have in mind is having code write
characters to the WLineEdit (and display them) one by one
at a rate of three or four characters per second.

What tools does Wt provide to do something like this, and
how should the manipulations be divided up between the
browser and the server?

If I were doing this on a desktop app, I would probably lock
the line-edit, use a timer to trigger writing each character
into the line-edit, and then unlock the line-edit when I was
done.

Any thoughts would be appreciated.


Thanks.


K. Frank
Koen Deforche
2015-01-05 08:22:25 UTC
Permalink
Hey,

I would do this with a small snippet of JavaScript code; e.g. a single
function that you can call with a line edit and a text.

fillAnimate(edit, text) { ... }

This code itself could use JavaScipt setTimeout() to perform the animation.

You can put this file in a JS file which you load using
WApplication::require(), and then you can use it for a particular line edit:

WLineEdit *ed = ... ;
WString text = ... ;

ed->doJavaScript("fillAnimate(" + ed->jsRef() + ", " +
text.jsStringLiteral() + ");");

Regards,
koen
Post by K. Frank
Hello List!
What would be a good way -- the Wt way -- to animate filling
in a WLineEdit? What I have in mind is having code write
characters to the WLineEdit (and display them) one by one
at a rate of three or four characters per second.
What tools does Wt provide to do something like this, and
how should the manipulations be divided up between the
browser and the server?
If I were doing this on a desktop app, I would probably lock
the line-edit, use a timer to trigger writing each character
into the line-edit, and then unlock the line-edit when I was
done.
Any thoughts would be appreciated.
Thanks.
K. Frank
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is
your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net
_______________________________________________
witty-interest mailing list
https://lists.sourceforge.net/lists/listinfo/witty-interest
K. Frank
2015-01-07 01:18:19 UTC
Permalink
Hi Koen!
Post by Koen Deforche
Hey,
I would do this with a small snippet of JavaScript code; e.g. a single
function that you can call with a line edit and a text.
Yes, doing this with javascript sounds like the right way to go.
(As I understand it, the animation would then be carried out on
the client side -- that is, by the browser executing the javascript.)
Post by Koen Deforche
fillAnimate(edit, text) { ... }
This code itself could use JavaScipt setTimeout() to perform the animation.
You can put this file in a JS file which you load using
WLineEdit *ed = ... ;
WString text = ... ;
ed->doJavaScript("fillAnimate(" + ed->jsRef() + ", " +
text.jsStringLiteral() + ");");
Thanks for sketching out some of the details. I will experiment
with this approach some time in the future.

I did implement a solution where I scheduled a sequence of
WTimer::singelShot calls spaced a few hundred milliseconds
apart that update the text so as to add one character at a time.

But it does seem "heavyweight" to orchestrate this animation on
the server, rather than pushing the processing to the browser.
Post by Koen Deforche
Regards,
koen
Thanks for your feedback.


K. Frank
Post by Koen Deforche
Post by K. Frank
Hello List!
What would be a good way -- the Wt way -- to animate filling
in a WLineEdit? What I have in mind is having code write
characters to the WLineEdit (and display them) one by one
at a rate of three or four characters per second.
...
Loading...