Question About accessing object

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

Question About accessing object

jhonny thio
Hi, i have one question

This is my code :

label = new qx.ui.toolbar.Button("Test");
this.add(label);
label.setUserData("id",1);
label.addEventListener("execute", this._onPilihKat, this);
....
....

_onPilihKat : function()
{
    how to access the label object here? example : how to get the userdata("id")?

    because if I use "this", it will refer to the container of label, not to the label
}


Thank you


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Question About accessing object

Petr Kobalíček
Hi jhonny,

I don't know if I help you, but try this:

_onPilihKat : function(e)
{
  var button = e.getTarget();
}

There are also getCurrentTarget() and getOriginalTarget() methods but
I know nothing about those;-)

Best regards
Petr

2008/7/20 jhonny thio <[hidden email]>:

> Hi, i have one question
>
> This is my code :
>
> label = new qx.ui.toolbar.Button("Test");
> this.add(label);
> label.setUserData("id",1);
> label.addEventListener("execute", this._onPilihKat, this);
> ....
> ....
>
> _onPilihKat : function()
> {
>     how to access the label object here? example : how to get the
> userdata("id")?
>
>     because if I use "this", it will refer to the container of label, not to
> the label
> }
>
>
> Thank you
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> qooxdoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Question About accessing object

jhonny thio
In reply to this post by jhonny thio
yes it works, you are wonderfull. thank you

----- Original Message ----
From: Petr Kobalíček <[hidden email]>
To: qooxdoo Development <[hidden email]>
Sent: Sunday, July 20, 2008 8:43:54 AM
Subject: Re: [qooxdoo-devel] Question About accessing object

Hi jhonny,

I don't know if I help you, but try this:

_onPilihKat : function(e)
{
  var button = e.getTarget();
}

There are also getCurrentTarget() and getOriginalTarget() methods but
I know nothing about those;-)

Best regards
Petr

2008/7/20 jhonny thio <[hidden email]>:

> Hi, i have one question
>
> This is my code :
>
> label = new qx.ui.toolbar.Button("Test");
> this.add(label);
> label.setUserData("id",1);
> label.addEventListener("execute", this._onPilihKat, this);
> ....
> ....
>
> _onPilihKat : function()
> {
>    how to access the label object here? example : how to get the
> userdata("id")?
>
>    because if I use "this", it will refer to the container of label, not to
> the label
> }
>
>
> Thank you
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> qooxdoo-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
Reply | Threaded
Open this post in threaded view
|

Re: Question About accessing object

Derrell Lipman
In reply to this post by jhonny thio
On Sun, Jul 20, 2008 at 10:17 AM, jhonny thio <[hidden email]> wrote:
Hi, i have one question

This is my code :

label = new qx.ui.toolbar.Button("Test");
this.add(label);
label.setUserData("id",1);
label.addEventListener("execute", this._onPilihKat, this);

The third parameter to addEventListener is the object which will become 'this' in the callback function.  It can be omitted, and the object on which addEventListener() was called will be substituted.  That would allow you to access the label object as 'this' in the callback.  You could also explicitly pass 'label' as the third parameter to addEventListener(), which is the same as omitting the third parameter.
 
_onPilihKat : function()
{
    how to access the label object here? example : how to get the userdata("id")?

If you either omitted the third parameter to addEventListner() or explicitly passed 'label' then you could here reference this.getUserData("id")
 
Derrell


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel