8

Having the following szenario: blurring a textBox (input) writes text to my status-Box (in certain conditions), and clicking a button also writes text to the status-Box.

Now when clicking the button it will blur my textBox if it is focused and that will cause the status-Box to flicker as first the blurHandler will write its result and then the clickHandler. As i want the result of the clickHandler to appear my idea is to let the blurHandler place an event at the end of the queue which checks whether a clickHandler has written a result before.

In Swing I would try SwingUtilities.invokeLater(Runnable). The equivalent in GWT is said to be the Scheduler but those deferred or finally commands seems always to run after the current event and before the next. So far i use Scheduler.scheduleFixedDelay with 100ms delay and hope it comes after the clickHanlder in each browser. See similar problem with answer.

I think there must be a better solution for this. How to really add an event to the end of the queue or is it impossible due to limitations of HTML?

Community
  • 1
  • 1
Zak_Rhol
  • 285
  • 3
  • 8
  • Note that your problem have *nothing* to do with HTML but with Javascript engines of various browser. Scheduler adds event to the end of the queue, but browser may generate next event after your event has completed. Does this effect appears in all browsers? – Danubian Sailor Mar 23 '12 at 08:21
  • yes the effect appears in all browsers – Zak_Rhol Mar 23 '12 at 08:46
  • I'm not sure if this is the best solution, but on textBox blur you may have to see if focus went to the specific button. It doesn't seem very elegant. Perhaps this link will help: http://stackoverflow.com/questions/7096120/how-to-determine-where-focus-went – nogridbag Mar 23 '12 at 14:56

1 Answers1

5

Try:

Scheduler.get().scheduleDeferred(new Command() {

                        @Override

                        public void execute() {
                                .......
                        }
                });

See

Class Scheduler

Andrzej Jozwik
  • 14,331
  • 3
  • 59
  • 68
  • I already tried this. Doing this in the blurHandler still makes the command to be executed before the clickHandler. I tried this in dev and production mode in FF, Chrome, Safari - same flickering effect in all browsers. – Zak_Rhol Mar 23 '12 at 08:46