canvas.addClickHandler(new ClickHandler() {
@Override
public void onClick(final ClickEvent event) {
final DrawableObject dobj = getObjectUnderCoordinates(event.getX(), event.getY());
if (dobj != null) {
final EnvObjectProperties eop = new EnvObjectProperties(dobj.getEnvObject());
eop.setPopupPositionAndShow(new EnvObjectProperties.PositionCallback() {
@Override
public void setPosition(int offsetWidth, int offsetHeight) {
int left = event.getX() + canvas.getAbsoluteLeft() + dobj.getCurrentWidth() / 4;
int top = event.getY() + canvas.getAbsoluteTop() - dobj.getCurrentHeight() / 2;
eop.setPopupPosition(left, top);
}
});
}
}
});
canvas.addMouseMoveHandler(new MouseMoveHandler() {
//TODO: maybe there is a better way making DrawableObjects implement MouseListener and transforming it on widgets
@Override
public void onMouseMove(final MouseMoveEvent event) {
GWT.log("On mouse over");
final DrawableObject dobj = getObjectUnderCoordinates(event.getX(), event.getY());
if (dobj != null) {
if (!dobj.isShowingBehavioursPanel()) //to avoid blinking
{
int left = canvas.getAbsoluteLeft();
int top = canvas.getAbsoluteTop();
dobj.showBehavioursPanel(left, top, mScaleFactor);
objectsShowingBehaviors.add(dobj);
}
} else {
for (DrawableObject dobj2 : objectsShowingBehaviors) {