attach listeners/handlers to widget, then do some DOM-stuff - listeners gone?

30 views
Skip to first unread message

Dennis Haupt

unread,
Nov 25, 2011, 10:41:05 AM11/25/11
to google-we...@googlegroups.com
hi community,

i wrote a little logic-attacher in gwt that is called from hand written javascript. i get an element by its id, wrap it in a flowpanel, wrap that in a table, put some buttons in the table and attach mouseover & clickhandlers to the buttons.

then i attach the whole thing to a div. everything works except the handlers - they simply are never called.

when doing everything in puregwt (no native dom manipulation, just gwt widgets & panels) it works fine. does moving elements in the dom tree destroy the handlers? if yes, are they repairable?



Tomasz Gawel

unread,
Nov 25, 2011, 7:06:57 PM11/25/11
to Google Web Toolkit
paste some code to enable more valid answer ;) ... but probably the
matter is the fragment below

> then i attach the whole thing to a div. everything works except the
> handlers - they simply are never called.

if you create a panel (and some widget in its hierarchy) an then
attach the panel's element to do DOM with use of "plain DOM methods"
the domHandlers will never be inited (or "sinked" in gwt-dialekt ;))
- look at onAttach and addDomHandler methods source of widget for
more :).

Vitrums

unread,
Nov 26, 2011, 8:31:48 AM11/26/11
to google-we...@googlegroups.com
I frequently use native .onmouseover/.onmouseout events in my animations, and I always try to follow some limitations, which can save me from a set of known unpredictable behaviours concerning this matter. First of all, defer all your handlers attachments as much, as you're sure, that calling a constructor will already have the correct getAbsoluteLeft() method call results at this point. Second thing is that, when you process these two events to enable/disable some UI effects for smoothness purposes have some default pauses to determine whether it's still necessary to call the mirrored animation, or it was just a micro-break like one, when you move a mouse from one element of <ul> list to another, while this list is attached to the listened DOM element. Also think about using Cell<...> objects as a possible substitutions for old-school Widget ones. 
Reply all
Reply to author
Forward
0 new messages