Finding a widget

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Finding a widget

Werner Thie
Hi

Speaking of late binding - is there an easy way to find a widget buried
somewhere down in the visual architecure?

Usage would be like

someWidget.findChildWidget('magic id').setValue('Thought so!);

Did I miss something in the docs or do I have to build such a mechanism
myself? (issuing id's, walking the child tree, returning a ref)

Thxs, Werner

------------------------------------------------------------------------------

_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Finding a widget

Derrell Lipman
On Thu, May 27, 2010 at 17:19, Werner Thie <[hidden email]> wrote:
Hi

Speaking of late binding - is there an easy way to find a widget buried
somewhere down in the visual architecure?

Usage would be like

someWidget.findChildWidget('magic id').setValue('Thought so!);

Yes. The "magic id" is called a hash code in qooxdoo. Each object of a class descended from qx.core.Object (just about all of 'em) has a hash code which you can retrieve using

  var hash = obj.toHashCode();

That hash code is also stored in the qooxdoo registry, so you can later locate the object given its hash code with

  var obj = qx.core.ObjectRegistry.fromHashCode(hash);

Is that what you're looking for?

Derrell


------------------------------------------------------------------------------


_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Finding a widget

Werner Thie
Derrell Lipman wrote:

> On Thu, May 27, 2010 at 17:19, Werner Thie <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hi
>
>     Speaking of late binding - is there an easy way to find a widget buried
>     somewhere down in the visual architecure?
>
>     Usage would be like
>
>     someWidget.findChildWidget('magic id').setValue('Thought so!);
>
>
> Yes. The "magic id" is called a hash code in qooxdoo. Each object of a
> class descended from qx.core.Object (just about all of 'em) has a hash
> code which you can retrieve using
>
>   var hash = obj.toHashCode();
>
> That hash code is also stored in the qooxdoo registry, so you can later
> locate the object given its hash code with
>
>   var obj = qx.core.ObjectRegistry.fromHashCode(hash);
>
> Is that what you're looking for?
>
Perfect, this does the trick nicely (and me not storing a gazillion
refs) - Thxs a bunch, Werner

------------------------------------------------------------------------------

_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Finding a widget

Derrell Lipman
On Thu, May 27, 2010 at 17:33, Werner Thie <[hidden email]> wrote:
>   var hash = obj.toHashCode();
>
> That hash code is also stored in the qooxdoo registry, so you can later
> locate the object given its hash code with
>
>   var obj = qx.core.ObjectRegistry.fromHashCode(hash);
>
> Is that what you're looking for?
>
Perfect, this does the trick nicely (and me not storing a gazillion
refs) - Thxs a bunch, Werner 

Great. The one caveat with that is that hash codes can be (are) reused after an object is disposed, so caveat programmer.

Derrell
 

------------------------------------------------------------------------------


_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel