On 8 juil, 19:39, Memo Sanchez <[email protected]> wrote:
> Thank you, it worked, this is what I did, in case someone is
> interested:
I'd rather do:
> buttonright_arrow.addMouseListener(new MouseListener()
> {
> boolean flag = false;
>
> private Timer timer = new Timer()
> {
> public void run()
> {
> flag = true;
> }
> };
>
> private Timer t = new Timer()
> {
> public void run()
> {
> if (flag)
> scrollToRight();
> }
> };
(a single timer, no "flag" field)
private Timer t = new Timer() {
@Override
public void run() {
scrollRight();
this.schedule(100);
}
};
> public void onMouseDown(Widget sender, int x, int y)
> {
> timer.schedule(1000);
> t.scheduleRepeating(100);
t.schedule(1000);
Re-scheduling the timer from itself prevents some weird behaviors: if
scrollRight takes more than 100ms, the next "timer tick" will be
delayed to "just after" scrollRight returns (more of less); which in
turns takes more than 100ms, delaying the next timer tick, etc. and
the "mouse up" will have to come in between "timer ticks". But
remember that "timer ticks" are queued in the event loop, so the
delayed "ticks" will still be executed before the "mouse up" event
really fire; and your app looks slugish and flaky.
See
http://googlecode.blogspot.com/2009/07/gmail-for-mobile-html5-series-using.html
and http://ejohn.org/blog/how-javascript-timers-work/ for a
description of how JavaScript timers work (setTimeout is .schedule()
and setInterval is .scheduleRepeating())
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---