On 03/09/2010 12:59 PM, marbin wrote:
> 
> I am building a custom widget using qx.html.Element objects to build the
> component.
> I have added a mouse listener to my element. My question is how to get back
> to the original qx.html.Element in the event listener callback.
> The object provided by the event (via getTarget()) is the DOM-element and
> not the qx.html.Element.
> Is there a way to get hold of this reference in the callback?
> 
> var cell = new qx.html.Element("td");
> cell.addListener("mousedown", this._cellMouseListener, this);
> ...
> 
> _cellMouseListener: function(event) {
>       var element = event.getTarget();
>         // This is not the original qx.html.Element.
>         // How do I get a reference to that?
> 
> }     


The issue here is that qx.html.* are only light wrapper classes around
the underlying DOM elements. Among other things, this also means that
you do *not* have qooxdoo events on this layer. What you can use, and
what you actually did in your code snippet, is registering for and
reacting on *native* browser events. So the "event" parameter that is
passed to your _cellMouseListener is a browser event object, is not
normalized (in the qooxdoo sense), and might vary between browsers.

So the interesting question is why would you want to base your custom
widget on qx.html.Element? Why not use classes from the qx.ui.* name
space where you have a much better abstraction?

If you insist on pursuing your initial approach, you might want to try
qx.ui.core.Widget#getWidgetByElement() which should return the qooxdoo
object for the DOM element. But I don't know how well this works with
qx.html.Element instances.

T.
                        

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to