Events

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

Events

Krycek
Hi List,

I'm trying to get the TreeFolder that was double clicked:

var node = new qx.ui.tree.TreeFolder ("first");
node.setUserData({a: 'b', c: 'd'});
treeView.getRoot().add(node);
node.addListener("dblclick", this._onTreeDblClick);

...
_onTreeDblClick: function(e)
{
            console.log (this.getUserData());
}

It is not working. Actually I would like to add a "dblclick" event listener in the tree, like so:

treeView.addListener("dblclick", this._onTreeDblClick, this); // just to keep all "this" references to the instance

but I'm a little lost with e.getTarget(), e.getRelatedTarget(), e.getOriginalTarget(), e.getCurrentTarget().

How to get that "user data" on "dblclick" event?



-------------------------------------------------------------------------
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: Events

Krycek
ops, now I saw that setUserData has 2 args
sorry for that :$

but can I get the Tree Item using the "dblclick" event in the Tree?

2008/8/6 Guilherme Aiolfi <[hidden email]>
Hi List,

I'm trying to get the TreeFolder that was double clicked:

var node = new qx.ui.tree.TreeFolder ("first");
node.setUserData({a: 'b', c: 'd'});
treeView.getRoot().add(node);
node.addListener("dblclick", this._onTreeDblClick);

...
_onTreeDblClick: function(e)
{
            console.log (this.getUserData());
}

It is not working. Actually I would like to add a "dblclick" event listener in the tree, like so:

treeView.addListener("dblclick", this._onTreeDblClick, this); // just to keep all "this" references to the instance

but I'm a little lost with e.getTarget(), e.getRelatedTarget(), e.getOriginalTarget(), e.getCurrentTarget().

How to get that "user data" on "dblclick" event?




-------------------------------------------------------------------------
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: Events

Ian Monroe-2
In reply to this post by Krycek
On Wed, Aug 6, 2008 at 2:49 PM, Guilherme Aiolfi <[hidden email]> wrote:

> Hi List,
>
> I'm trying to get the TreeFolder that was double clicked:
>
> var node = new qx.ui.tree.TreeFolder ("first");
> node.setUserData({a: 'b', c: 'd'});
> treeView.getRoot().add(node);
> node.addListener("dblclick", this._onTreeDblClick);
>
> ...
> _onTreeDblClick: function(e)
> {
>             console.log (this.getUserData());
> }
>
> It is not working. Actually I would like to add a "dblclick" event listener
> in the tree, like so:
>
> treeView.addListener("dblclick", this._onTreeDblClick, this); // just to
> keep all "this" references to the instance
>
> but I'm a little lost with e.getTarget(), e.getRelatedTarget(),
> e.getOriginalTarget(), e.getCurrentTarget().
>
> How to get that "user data" on "dblclick" event?

I would just define a function anonymously within the addListener
call, then it has access to all those variables in the scope. This is
probably my favorite thing about event programming in JavaScript vs.
C++. Granted, if you look at the email I sent you can see that it can
get a little out of hand when you start nesting the event handlers. It
would probably work if you defined the function within the calling
function, JavaScript scoping is funky like that.

Ian

-------------------------------------------------------------------------
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: Events

Fabian Jakobs
Administrator
In reply to this post by Krycek
Guilherme Aiolfi schrieb:
> ops, now I saw that setUserData has 2 args
> sorry for that :$
>
> but can I get the Tree Item using the "dblclick" event in the Tree?

If you are using 0.8 you can try the following code:

tree.addListener("dblclick", function(e) {
    var item = tree.getTreeItem(e.getTarget());
}, this);


The event target is the widget immediately below the mouse cursor. What
"getTreeItem" does is walking up the widget hierarchy starting from the
given widget until it finds a tree item and returns it.

Best Fabian

--
Fabian Jakobs
JavaScript Framework Developer

1&1 Internet AG
Brauerstraße 48
76135 Karlsruhe

Amtsgericht Montabaur HRB 6484

Vorstand: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Thomas Gottschlich, Matthias Greve, Robert Hoffmann, Markus Huhn, Oliver Mauss, Achim Weiss
Aufsichtsratsvorsitzender: Michael Scheeren


-------------------------------------------------------------------------
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: Events

Krycek
Thank you, Fabian

I end up with this code that does exctly that:

var element = e.getTarget();
while (!(element instanceof qx.ui.tree.TreeFolder))
       element = element.getLayoutParent();

Any disadvantage of doing this way?

What if .getTarget could receive a argument saying what kind of object we are expecting:

e.getTarget() -> returns the widget below the mouse cursor as it is now

e.getTarget(qx.ui.tree.AbstractTreeItem) -> returns the first object that is an instance of "qx.ui.tree.TreeFolder" when walking up the widget hierarchy


2008/8/7 Fabian Jakobs <[hidden email]>
Guilherme Aiolfi schrieb:
> ops, now I saw that setUserData has 2 args
> sorry for that :$
>
> but can I get the Tree Item using the "dblclick" event in the Tree?

If you are using 0.8 you can try the following code:

tree.addListener("dblclick", function(e) {
   var item = tree.getTreeItem(e.getTarget());
}, this);


The event target is the widget immediately below the mouse cursor. What
"getTreeItem" does is walking up the widget hierarchy starting from the
given widget until it finds a tree item and returns it.

Best Fabian

--
Fabian Jakobs
JavaScript Framework Developer

1&1 Internet AG
Brauerstraße 48
76135 Karlsruhe

Amtsgericht Montabaur HRB 6484

Vorstand: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Thomas Gottschlich, Matthias Greve, Robert Hoffmann, Markus Huhn, Oliver Mauss, Achim Weiss
Aufsichtsratsvorsitzender: Michael Scheeren


-------------------------------------------------------------------------
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: Events

Fabian Jakobs
Administrator
Guilherme Aiolfi schrieb:
> Thank you, Fabian
>
> I end up with this code that does exctly that:
>
> var element = e.getTarget();
> while (!(element instanceof qx.ui.tree.TreeFolder))
>        element = element.getLayoutParent();
>
> Any disadvantage of doing this way?
This is basically the same as the "getTreeItem" method so there should
be no disadvantages.

>
> What if .getTarget could receive a argument saying what kind of object
> we are expecting:
>
> e.getTarget() -> returns the widget below the mouse cursor as it is now
>
> e.getTarget(qx.ui.tree.AbstractTreeItem) -> returns the first object
> that is an instance of "qx.ui.tree.TreeFolder" when walking up the
> widget hierarchy
I would rather leave the method as it is. This is a rare use case and I
don't want to change a core method like getTarget for this.


Best Fabian




>
>
> 2008/8/7 Fabian Jakobs <[hidden email]
> <mailto:[hidden email]>>
>
>     Guilherme Aiolfi schrieb:
>     > ops, now I saw that setUserData has 2 args
>     > sorry for that :$
>     >
>     > but can I get the Tree Item using the "dblclick" event in the Tree?
>
>     If you are using 0.8 you can try the following code:
>
>     tree.addListener("dblclick", function(e) {
>        var item = tree.getTreeItem(e.getTarget());
>     }, this);
>
>
>     The event target is the widget immediately below the mouse cursor.
>     What
>     "getTreeItem" does is walking up the widget hierarchy starting
>     from the
>     given widget until it finds a tree item and returns it.
>
>     Best Fabian
>
>     --
>     Fabian Jakobs
>     JavaScript Framework Developer
>
>     1&1 Internet AG
>     Brauerstraße 48
>     76135 Karlsruhe
>
>     Amtsgericht Montabaur HRB 6484
>
>     Vorstand: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich,
>     Thomas Gottschlich, Matthias Greve, Robert Hoffmann, Markus Huhn,
>     Oliver Mauss, Achim Weiss
>     Aufsichtsratsvorsitzender: Michael Scheeren
>
>
>     -------------------------------------------------------------------------
>     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=/
>     <http://moblin-contest.org/redirect.php?banner_id=100&url=/>
>     _______________________________________________
>     qooxdoo-devel mailing list
>     [hidden email]
>     <mailto:[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
>  


--
Fabian Jakobs
JavaScript Framework Developer

1&1 Internet AG
Brauerstraße 48
76135 Karlsruhe

Amtsgericht Montabaur HRB 6484

Vorstand: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Thomas Gottschlich, Matthias Greve, Robert Hoffmann, Markus Huhn, Oliver Mauss, Achim Weiss
Aufsichtsratsvorsitzender: Michael Scheeren


-------------------------------------------------------------------------
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