I would like to know what the sinkEvent do ? If it's a method which
only listen the events of an object, or if it also implement all
Widgets event (as onmousedown, onmousemove....)
And, does a widget have all the event by default in javascript in
their div, or there are added by the sinkEvent ?.
Thanks in advance for your answers :)
NB: you can't just sinkEvents and assume stuff will work; you need
everything involved to use GWT's widget system. For example, if you
create a custom widget that uses sinkEvents, then toss it's
"getElement()" into a div using DOM.appendChild, events won't work.
NB2: You sinkEvents something, then you override onBrowserEvent and
handle events. Simple. Just look at FocusWidget, for example.
On Apr 17, 5:55 pm, "Alex Gorisse [pleyo]" <alexgori...@gmail.com>
wrote:
I really would like to build a performed Drag And Drop system for GWT,
but I cannot have so much answer :'(
For the rests, it still doesn't answer exactly the javascript side
question, and how look like the code :
For exemple, if you have a sinkEvent(Event.onMouseDown), does it
appear like this in javascript :
/******
<div onmousedown="myBrowserCase"></div>
****/
Or like this :
/*****
<div onmousedown="myBrowserEvent" onmousemove="" onmouseup=""
onclick="" onfocus="" on...... >
*****/
Because I still do not understand why all Widgets don't implement a
simple MouseListener.... So that Javascript do.... And why we justly
have to extends a widget so that we can access to the MouseListener
events for example ?
Thanks it is really important to me :)
SinkEvent exists to allow a specific element say it wants to receive
the following events. AS per event bubbling if the element doesnt
consume the event its parent is given a go. THis continues until the
top of the heirarchy is found or some element consumes the event and
cancels the bubble.
On Apr 18, 2:40 am, "Alex Gorisse [pleyo]" <alexgori...@gmail.com>
As every third post or so on this forum seems to indicate, there are
plenty of DnD efforts going on already. I know the windowing toolkit
allows you to drag windows around, why don't you look at that source
to see a hint of how to do it?
Last question: What is that [pleyo] thing in your name?
On Apr 17, 6:40 pm, "Alex Gorisse [pleyo]" <alexgori...@gmail.com>
You should look into the GWT code (gwt-user.jar - in particular the
DOM classes and all the DOMImpl* classes (e.g. DOMImplStandard,
DOMImplIE6, etc) to get a full understanding of the GWT event handling
and the widgets - for example, not all widgets are div elements.
In essence, and this is a gross simplification which is therefore open
to some interpretation but should give you an idea where you need to
start looking to fully understand the GWT event mechanisms (and it is
based on observations for the future 1.4 release, but broadly valid
for 1.3):
* GWT places global JavaScript event handlers at the window level for
your application and effectively handles the event mechanism itself -
look at the init() and sinkEvent() methods in the various DOMImpl*
classes.
* The sinkEvent() method is the internal process of registering that a
widget wishes to listen to particular events. Each event type you
wish a widget to listen to has to be added via its sinkEvent()
method. In the DOM implementation classes you'll see that the
sinkEvent() method is implemented by placing an appropriate event
handler on the widget's DOM element that points directly to GWT's
global event handlers ($wnd.__dispatchEvent, for example).
* When an event happens on your widget that it has sunk, then the GWT
global event handler receives notification. That handler then performs
some validity checking (for example look at the IE6 implementation of
$wnd.__dispatchEvent which is created/defined in the DOMImplIE6 init()
method), and then, after jumping around between a few classes, the
widget's onBrowserEvent() method is called.
* The code that you have written in the onBrowserEvent() method for
the event that has been passed is then executed.
If you have an IDE then you should be able to use that to see the
class hierarchy and call paths between related methods. You should
also be able to use your IDE's debug mode to inspect widgets as they
are created and see their DOM representation being constructed as you
sink events.
As said, the above is quite a gross simplification of the process, and
open to some interpretation, but that's life if you try and shrink the
explanation down to a few bullet points. As Reinier mentions, GWT is
all open source and so you can go through all the code to deduce what
is happening if you invest the time. Key classes are:
com.google.gwt.user.client.DOM
com.google.gwt.user.client.impl.DOMImpl
com.google.gwt.user.client.impl.DOMImplStandard
com.google.gwt.user.client.impl.DOMImplIE6
com.google.gwt.user.client.impl.DOMImplOpera
com.google.gwt.user.client.impl.DOMImplMozilla
com.google.gwt.user.client.impl.DOMImplSafari
To fully understand GWT's event handling mechanism you should probably
have a usable understanding of
* the W3C and IE event models,
* GWT's JavaScript Native Interface (JSNI) syntax (since there is a
fair amount of crossing the boundary between GWT Java and JavaScript
in those mentioned classes)
* the hierarchy of widget classes, e.g. DOM->DOMImpl, UIObject->Widget-
>....->YourWidget
....and a bit of knowledge on GWT's class replacement mechanism
(deferred binding) wouldn't hurt in your quest to understand how it
all plugs together.
<shameless plug>we've done a lot of that work for you in the "GWT In
Action" book, explaining it all with lots of diagrams and code
samples</shameless plug>
Are you hooked into the ongoing discussions on GWT's Drag and Drop RR
where people are looking at what the future API for GWT native drag
and drop would look like (along with lots of samples from where other
people have come up with solutions)?
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/d2e7f7c1ea93e423
http://groups.google.com/group/Google-Web-Toolkit-Contributors/browse_thread/thread/205e8d76a6d047a9/70eaaf99a6ed70e1?lnk=gst&q=drag&rnum=1#)
Good luck with your implementation!
//Adam
Co-author GWT In Action (http://www.manning.com/hanson)
GWT Application: http://dashboard.manning-sandbox.com/
On Apr 17, 5:55 pm, "Alex Gorisse [pleyo]" <alexgori...@gmail.com>
wrote:
-= Mat
@Renier Zwitserloot : Pleyo is the name of my company, I just have to
do a Gwt Drag Drop system for them...
But, All yours answers don't answer my ultimate one, why MouseListener
or KeyBoardListener aren't implemented in all Widgets ?