I've created a:
Has...Handlers interface
bunch of Handler classes (DropHandler, DragEnterHandler, etc)
and a bunch of Event classes that extend MouseEvent (DropEvent,
DragEnterEvent, etc).
I've also created a DropTarget Widget that implements the
Has...Handlers interface which accepts a Widget as a param in its
contructor which then calls setElement() passing in widget.getElement
()...
I then add this DropTarget to the RootPanel (for testing purposes) in
an onModuleLoad.
But I'm getting a low level error ("Something other than an int was
returned from JSNI method"):
com.google.gwt.dev.shell.HostedModeException: Something other than an
int was returned from JSNI method
'@com.google.gwt.user.client.impl.DOMImpl::eventGetTypeInt(Ljava/lang/
String;)': JS value of type undefined, expected int
at com.google.gwt.dev.shell.JsValueGlue.getIntRange
(JsValueGlue.java:266)
at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:144)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeInt
(ModuleSpace.java:242)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeInt
(JavaScriptHost.java:75)
at com.google.gwt.user.client.impl.DOMImpl.eventGetTypeInt
(DOMImpl.java)
at com.google.gwt.user.client.Event$.getTypeInt(Event.java:491)
at com.google.gwt.user.client.ui.Widget.addDomHandler(Widget.java:
184)
at
com.applegreen.gwt.html5.dnd.client.DropTarget.addDragEnterHandler
(DropTarget.java:44)
at com.applegreen.gwt.test.client.DragAndDropTest.onModuleLoad
(DragAndDropTest.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:
369)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule
(OophmSessionHandler.java:185)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection
(BrowserChannelServer.java:380)
at com.google.gwt.dev.shell.BrowserChannelServer.run
(BrowserChannelServer.java:222)
at java.lang.Thread.run(Unknown Source)
Can anyone shed any light on what I'm doing wrong or what method I
should have overidden (I'm not a java programmer btw)??
Cheers,
Dave
So in order to add the new html5 events I would need to add my own
DOMImpl class... which I can't seem to do... I appear to be trying to
accomplish the same task as the person posting here
http://groups.google.com/group/google-web-toolkit/browse_thread/thread/560ff832885745b0#
This doesn't appear to be possible (or at least simple or obvious or
documented)...
Its frustrating for me as I've already written the (few lines of)
javascript code to do this - I'm using GWT for a project so really I
need a GWT implementation...
Do any of the GWT experts have any suggestions??
On Dec 30, 4:24 pm, DaveC <david.andrew.chap...@googlemail.com> wrote:
> I'm probably not doing this the right way but, I've been trying to
> extend MouseEvent to support HTML5 Drag and Drop (drag, dragenter,
> etc. etc.).
>
> I've created a:
>
> Has...Handlers interface
> bunch of Handler classes (DropHandler, DragEnterHandler, etc)
> and a bunch of Event classes that extend MouseEvent (DropEvent,
> DragEnterEvent, etc).
>
> I've also created a DropTarget Widget that implements the
> Has...Handlers interface which accepts a Widget as a param in its
> contructor which then calls setElement() passing in widget.getElement
> ()...
>
> I then add this DropTarget to the RootPanel (for testing purposes) in
> an onModuleLoad.
>
> But I'm getting a low level error ("Something other than an int was
> returned from JSNI method"):
>
> com.google.gwt.dev.shell.HostedModeException: Something other than an
> int was returned from JSNI method
> '...@com.google.gwt.user.client.impl.DOMImpl::eventGetTypeInt(Ljava/lang/
Here's my DropEvent class...
public class DropEvent extends DomEvent<DropHandler> {
/**
* Event type for drop events. Represents the meta-data associated
with this
* event.
*/
private static final Type<DropHandler> TYPE = new Type<DropHandler>
("drop",
new DropEvent());
/**
* Gets the event type associated with drop events.
*
* @return the handler type
*/
public static Type<DropHandler> getType() {
return TYPE;
}
/**
* Protected constructor, use
* {@link DomEvent#fireNativeEvent
(com.google.gwt.dom.client.NativeEvent,
com.google.gwt.event.shared.HasHandlers)}
* to fire drop events.
*/
protected DropEvent() {
}
@Override
public Type<DropHandler> getAssociatedType() {
return TYPE;
}
@Override
protected void dispatch(DropHandler handler) {
handler.onDrop(this);
}
}
... is there something I'm missing... and my DOMImpl class:
public class DOMImplMozillaHtml5 extends DOMImplMozillaOld {
public native int eventGetTypeInt(String eventType) /*-{
switch (eventType) {
case "blur": return 0x01000;
case "change": return 0x00400;
case "click": return 0x00001;
case "dblclick": return 0x00002;
case "focus": return 0x00800;
case "keydown": return 0x00080;
case "keypress": return 0x00100;
case "keyup": return 0x00200;
case "load": return 0x08000;
case "losecapture": return 0x02000;
case "mousedown": return 0x00004;
case "mousemove": return 0x00040;
case "mouseout": return 0x00020;
case "mouseover": return 0x00010;
case "mouseup": return 0x00008;
case "scroll": return 0x04000;
case "error": return 0x10000;
case "mousewheel": return 0x20000;
case "DOMMouseScroll": return 0x20000;
case "contextmenu": return 0x40000;
case "paste": return 0x80000;
case "drop": return 0x00001;
case "dragdrop": return 0x00001;
case "dragleave": return 0x00001;
case "dragover": return 0x00001;
case "dragenter": return 0x00001;
}
}-*/;
}
On Dec 31, 12:24 am, DaveC <david.andrew.chap...@googlemail.com>
wrote:
> OK, From what I have since found out is that *all* the native browser
> events are stored in a JSNI method in the DOMImpl class here
> DOMImpl.eventGetTypeInt(String name)... which is why the exception was
> being thrown (there is no "drop", "dragenter", etc events defined).
>
> So in order to add the new html5 events I would need to add my own
> DOMImpl class... which I can't seem to do... I appear to be trying to
> accomplish the same task as the person posting herehttp://groups.google.com/group/google-web-toolkit/browse_thread/threa...