Hi,

I'm trying to customize qx.ui.menu.Button. I need one extra
qx.ui.basic.Label called "price" between Button/label and Button/shortcut.
And I get this error: Assertion error! Wrong 'left' argument. The layout of
the widgetqx.ui.menu.Menu[204-0] returned an invalid size hint!: Expected
value to be an integer but found NaN!.
My code is:

qx.Class.define("my.ui.MenuButtonWithPrice",
{
  extend : qx.ui.menu.Button,

  construct : function(label, icon, command, price)
  {
    this.base(arguments, label, icon, command);
    if (price != null) {
      this.setPrice(price);
    }
  },

  properties :
  {
    price :
    {
      check : "String",
      apply : "_applyPrice",
      nullable : true,
      event: "changePrice"
    }
  },

  members :
  {
    _createChildControlImpl : function(id, hash)
    {
      var control;

      switch(id)
      {
        case "price":
          control = new qx.ui.basic.Label;
          control.setAnonymous(true);
          this._add(control, {column:2});
          break;

        case "shortcut":
          control = new qx.ui.basic.Label;
          control.setAnonymous(true);
          if (!this.getShowCommandLabel()) {
            control.exclude();
          }
          this._add(control, {column:3});
          break;

        case "arrow":
          control = new qx.ui.basic.Image;
          control.setAnonymous(true);
          this._add(control, {column:4});
          break;
      }

      return control || this.base(arguments, id);
    },

    getChildrenSizes : function()
    {
      var priceWidth = 0;
      var sizes = this.base(arguments);

      if (this._isChildControlVisible("price"))
      {
        var price = this.getChildControl("price");
        priceWidth = price.getMarginLeft() + price.getSizeHint().width +
price.getMarginRight();
      }

      sizes.splice(2, 0, priceWidth);
      return sizes;
    },

    _applyPrice : function(value, old)
    {
      if (value) {
        this._showChildControl("price").setValue(value);
      } else {
        this._excludeChildControl("price");
      }
    }
  }
});
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to