Very interesting this test from the Firebug Console:

Test 1:

     new qx.ui.basic.Label('david')._computePreferredInnerWidth()==38

Test 2:

var et = new qx.ui.basic.Label('david');
et.setLocation(200,200);
et.setZIndex(1000);
et.addToDocument()
et.setBackgroundColor('#ff0')
et._computePreferredInnerWidth()==26


Conclusion: the value reported depends on if the label has been added or
not.

Is this normal?

Relevant source code of Label.js:

    _computeObjectNeededDimensions : function()
    {
      // get node
      var element = this.self(arguments)._getMeasureNode();
      var style = element.style;

      // sync styles
      var source = this._styleProperties;
      style.fontFamily = source.fontFamily || "";
      style.fontSize = source.fontSize || "";
      style.fontWeight = source.fontWeight || "";
      style.fontStyle = source.fontStyle || "";

      // apply html
      if (this._isHtml)
      {
        element.innerHTML = this._content;
      }
      else
      {
        element.innerHTML = "";
        qx.dom.Element.setTextContent(element, this._content);
      }

      // store values
      this._cachedPreferredInnerWidth = element.scrollWidth;
      this._cachedPreferredInnerHeight = element.scrollHeight;
    },

    _computePreferredInnerWidth : function()
    {
      this._computeObjectNeededDimensions();
      return this._cachedPreferredInnerWidth;
    },



dperez wrote:
> 
> Hi,
> 
> In qooxdoo 0.6.6 I used to use this code for measuring the width of text:
> 
> (new qx.ui.basic.Label('My text')).getPreferredBoxWidth()
> 
> In qooxdoo 0.7, I receive very high values.  For instance for a label
> whose measured real width is 170 pixels, a value of 240 is returned.   
> 
> What may be the cause of this inaccuracy?
> Is this the best method of measuring width of text?
> 
> Thanx for any answer.
> 
> Regards,
> David
> 

-- 
View this message in context: 
http://www.nabble.com/Measuring-text-tf3963113.html#a11247337
Sent from the qooxdoo-devel mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to