moldoe
1 Jun 2009, 1:39 PM
I'm using the GWTCanvas class from GWT Incubator project. When I was using GXT 1.2, I extended this class and added browser event handling to it by implementing SourcesMouseEvents and overriding Widget.onBrowserEvent(). Mouse events were firing fine on this new custom canvas. Now with GXT 2.0 the same implementation stoped working. I even tried to change the deprecated API that I was using with the new EventHandler API. It still didn't work. Than I noticed that I have this problem only if the canvas Widget is added to a GXT Container. If I add the canvas directly to the RootPanel events work fine.
Is this a bug in GXT implemetation or do I have to do it different way?
Here is my code. It relies on GWTCanvas from gwt-incubator for GWT 1.6.
public class Test implements EntryPoint {
public void onModuleLoad() {
TCCanvas2 canvas = new TCCanvas2();
canvas.setBackgroundColor(Color.YELLOW);
canvas.addMouseDownHandler(new MouseDownHandler() {
@Override
public void onMouseDown(MouseDownEvent event) {
MessageBox.info("MouseDownHandler.onMouseDown",
"Coords: " + event.getX() + ", " + event.getY(), null);
}
});
Viewport viewport = new Viewport();
viewport.add(canvas);
RootPanel.get().add(viewport);
}
}
public class TCCanvas2 extends GWTCanvas implements HasAllMouseHandlers, HasClickHandlers {
public TCCanvas2() {
}
public TCCanvas2(int coordX, int coordY) {
super(coordX, coordY);
}
public TCCanvas2(int coordX, int coordY, int pixelX, int pixelY) {
super(coordX, coordY, pixelX, pixelY);
}
@Override
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
return addDomHandler(handler, MouseDownEvent.getType());
}
@Override
public HandlerRegistration addMouseUpHandler(MouseUpHandler handler) {
return addDomHandler(handler, MouseUpEvent.getType());
}
@Override
public HandlerRegistration addMouseOutHandler(MouseOutHandler handler) {
return addDomHandler(handler, MouseOutEvent.getType());
}
@Override
public HandlerRegistration addMouseOverHandler(MouseOverHandler handler) {
return addDomHandler(handler, MouseOverEvent.getType());
}
@Override
public HandlerRegistration addMouseMoveHandler(MouseMoveHandler handler) {
return addDomHandler(handler, MouseMoveEvent.getType());
}
@Override
public HandlerRegistration addMouseWheelHandler(MouseWheelHandler handler) {
return addDomHandler(handler, MouseWheelEvent.getType());
}
@Override
public HandlerRegistration addClickHandler(ClickHandler handler) {
return addDomHandler(handler, ClickEvent.getType());
}
Thanks,
Daniel
Windows XP
Hosted Mode
FF3
GXT 2.0-m2
JDK 1.6.4
Is this a bug in GXT implemetation or do I have to do it different way?
Here is my code. It relies on GWTCanvas from gwt-incubator for GWT 1.6.
public class Test implements EntryPoint {
public void onModuleLoad() {
TCCanvas2 canvas = new TCCanvas2();
canvas.setBackgroundColor(Color.YELLOW);
canvas.addMouseDownHandler(new MouseDownHandler() {
@Override
public void onMouseDown(MouseDownEvent event) {
MessageBox.info("MouseDownHandler.onMouseDown",
"Coords: " + event.getX() + ", " + event.getY(), null);
}
});
Viewport viewport = new Viewport();
viewport.add(canvas);
RootPanel.get().add(viewport);
}
}
public class TCCanvas2 extends GWTCanvas implements HasAllMouseHandlers, HasClickHandlers {
public TCCanvas2() {
}
public TCCanvas2(int coordX, int coordY) {
super(coordX, coordY);
}
public TCCanvas2(int coordX, int coordY, int pixelX, int pixelY) {
super(coordX, coordY, pixelX, pixelY);
}
@Override
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
return addDomHandler(handler, MouseDownEvent.getType());
}
@Override
public HandlerRegistration addMouseUpHandler(MouseUpHandler handler) {
return addDomHandler(handler, MouseUpEvent.getType());
}
@Override
public HandlerRegistration addMouseOutHandler(MouseOutHandler handler) {
return addDomHandler(handler, MouseOutEvent.getType());
}
@Override
public HandlerRegistration addMouseOverHandler(MouseOverHandler handler) {
return addDomHandler(handler, MouseOverEvent.getType());
}
@Override
public HandlerRegistration addMouseMoveHandler(MouseMoveHandler handler) {
return addDomHandler(handler, MouseMoveEvent.getType());
}
@Override
public HandlerRegistration addMouseWheelHandler(MouseWheelHandler handler) {
return addDomHandler(handler, MouseWheelEvent.getType());
}
@Override
public HandlerRegistration addClickHandler(ClickHandler handler) {
return addDomHandler(handler, ClickEvent.getType());
}
Thanks,
Daniel
Windows XP
Hosted Mode
FF3
GXT 2.0-m2
JDK 1.6.4