Re: [qooxdoo-devel] label.getBounds() doesn't updated properly?

2010-09-13 Thread danovics

Hello thron!

Thank you for your help (again (and again))!
I'm gonna try this workoround in my app.

Best regards
Daniel
-- 
View this message in context: 
http://qooxdoo.678.n2.nabble.com/label-getBounds-doesn-t-updated-properly-tp5525711p5526299.html
Sent from the qooxdoo mailing list archive at Nabble.com.

--
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing
http://p.sf.net/sfu/novell-sfdev2dev
___
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


Re: [qooxdoo-devel] label.getBounds() doesn't updated properly?

2010-09-13 Thread thron7


On 09/13/2010 12:31 PM, danovics wrote:
> 
> Hi
> 
> I've found an intresting issue. Hope someone could help me with it.
> I've a label which changes its value in runtime.
> I added a 'changeValue' to this label, with a function to get the actual
> width of the label using getBounds().
> The proplem is that it does't return the width of the label with new value,
> but the width corresponding to the label's old value.
> 
> I made a little playground example for this: http://tinyurl.com/39sgmlb

Playground sample nicely done.

The issue here is that the label listener is invoked as soon as the
'value' *property* changes - which does *not* imply that the rendering
of that property has already changed (as all rendering is done
asynchronously in qooxdoo). So the DOM is typically not updated at this
point in time, and the .getBounds() call (which operates on the DOM)
retrieves the old value.

One way to get around that is to explicitly flush the rendering queues:

  this.label.addListener("changeValue", function(e)
  {
var bounds = this.getBounds();
qx.ui.core.queue.Manager.flush();   // <-- HERE
that.log.setValue("widht of red label: " + this.getBounds().width);
  });

Here is the full example: http://tinyurl.com/266woeq

Mind, though, that both .getBounds and .flush methods are expensive, so
you shouldn't be doing this in a tight loop or a recurring timer with
high frequency. In an event handler that reacts on user input it should
be ok.

T.

--
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing
http://p.sf.net/sfu/novell-sfdev2dev
___
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel