On Sat, Dec 5, 2009 at 10:58, smartjo <[email protected]> wrote:

>
> Hi skar,
>                    Thank s for ur suggestion. I tested that way and here is
> the code.
>
>                        var doc = this.getRoot();
>                         var t1 = new qx.ui.form.TextField();
>                        t1.addListener('appear',function(){alert('creating
> t1');},this,false);
>
>                      var t2 = new qx.ui.form.TextField();
>                       t2.addListener('appear',function(){alert('creating
> t2');},this,false);
>
>                         var t3 = new qx.ui.form.TextField();
>                      t3.addListener('appear',function(){alert('creating
> t3');},this,false);
>
>                        doc.add(t1,{left:10,top:30})
>                       alert(1);
>                     doc.add(t2,{left:100,top:30})
>                     alert('2');
>                     doc.add(t3,{left:200,top:30})
>                     alert('3');
>
> And the result was like this. t1 appeared first and its event handler was
> executed. but after that the event handlers for t2 nd t3 was executed after
> alert(3) was executed. their event handlers were not  executed immediately
> they were added.  I hope you understand. Any solution for this?
>

You haven't stated what you're really trying to accomplish. If your goal is
to do synchronous actions, requiring that one thing be COMPLETE before the
next line of code is executed, you'll likely want to reconsider your design.
Widgets are added to a queue when you do doc.add(), and rendered some time
later. The reason that t2 and t3 appeared at the same time, is that during
the t1 alert(), when the system was otherwise idle,there was time for those
two other elements to be rendered. Their appear handlers were both queued,
and called in turn.

You could accomplish this simple example as follows:

var doc = this.getRoot();
var t1 = new qx.ui.form.TextField();
doc.add(t1,{left:10,top:30});
t1.addListener(
  "appear",
  function(e)
  {
    alert("1");
    var t2 = new qx.ui.form.TextField();
    doc.add(t2,{left:100,top:30});
    t2.addListener(
      "appear",
      function(e)
      {
        alert("2");
        var t3 = new qx.ui.form.TextField();
        doc.add(t3,{left:200,top:30});
        t2.addListener(
          "appear",
          function(e)
          {
            alert("3");
          });
      });
  });

Clearly this isn't a nice way to have to write your application.

An nicer way is to use qx.ui.progressive.Progressive with the with the
function caller renderer (qx.ui.progressive.renderer.FunctionCaller). An
example of this can be seen in the demobrowser, at
http://demo.qooxdoo.org/current/demobrowser/#progressive~ProgressiveLoader.html

I really think, though, that you need to reconsider your design. Application
design should not typically depend on when the rendering occurs. That is
necessary only in very rare circumstances.

Derrell
------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to