Hi Alexei,
Hello, List

Is there any way to access the qooxdoo widget somehow except the direct approach (by name in the code)?

Here the example:
// Application main function
qx.Proto.main = function(e) {
        var layout = new qx.ui.core.VerticalBoxLayout();
        layout.addToDocument();

        var btnTest = new qx.ui.form.Button("Test");
        layout.add(btnTest);    
}

Question:
Is there some call like this:
qx.core.some_ns.someGlobalCall()....
to access layout and btnTest?

I have written a simple widget registry mixin for the api viewer. this mixin adds an 'id' property to each widget and a 'getWidgetById' method.

qx.Class.include(qx.ui.core.Widget, apiviewer.MWidgetRegistry);
...

var btn = new qx.ui.form.Button("OK");
btn.setId("okBtn");

...

var btn = this.getWidgetById("okBtn");
// or
var btn = apiviewer.MWidgetRegistry.getWidgetById("okBtn");

I think, it would be easy to implement something like this for your 0.6 app.

Best Fabian


qx.Mixin.define("apiviewer.MWidgetRegistry",
{
  
  properties :
  {
    id : {
      check : "String",
      apply : "_applyId",
      nullable : true,
      init : null
    }
  },

  members :
  {
    _applyId : function(id, oldId)
    {
      var statics = apiviewer.MWidgetRegistry;
      if (oldId) {
        statics.unregister(this, oldId);
      }
      if (id) {
        statics.register(this, id);
      }
    },
    
    getWidgetById : function(id)
    {
      return apiviewer.MWidgetRegistry.getWidgetById(id);
    }
        
  },

  statics :
  {
    __objectDb : {},

    /**
     * Returns the widget registered under the given id by [EMAIL PROTECTED] 
#register}
     *
     * @param id {String} the id of the widget
     * @return {qx.ui.core.Widget} the widget.
     */
    getWidgetById : function(id)
    {
      return this.__objectDb[id];
    },

    /**
     * Registers a widget under the given widget id to be used with
     * [EMAIL PROTECTED] #getWidgetById}.
     *
     * @param widget {qx.ui.core.Widget} the widget to register
     * @param id {String} the id of the widget.
     */
    register : function(object, id)
    {    
      if (this.__objectDb[id]) {
        throw new Error("An object with the id '"+id+"' already exists.");
      }
      this.__objectDb[id] = object;
    },
    
    unregister : function(object, id)
    {    
      if (this.__objectDb[id] !== object) {
        throw new Error("The object is not registered with the id '"+id+"'.");
      }
      delete(this.__objectDb[id]);
    }
        
  }

});
-------------------------------------------------------------------------
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