Во всем коде, который я делал в прошлом, я никогда не использовал «this» для идентификации своего класса, я передал класс в.
Например: изменить это:
private native void addNativeMouseWheelListener(String id) /*-{
function mouseOverHandler(e) {
$wnd.addEventListener("DOMMouseScroll", scrollWheelMove, false);
}
function mouseOutHandler(e) {
$wnd.removeEventListener("DOMMouseScroll", scrollWheelMove, false);
}
function scrollWheelMove(e) {
if ($wnd.event || $wnd.Event) {
if (!e) e = $wnd.event;
if (e.wheelDelta <= 0 || e.detail > 0 ) {
$wnd.alert("DOWN");
} else {
this.@com.proprintsgear.design_lab.client.ValueBox::increaseValue()();
}
this.@com.proprintsgear.design_lab.client.ValueBox::fireChange()();
}
}
var box=$doc.getElementById(id);
box.addEventListener("mouseout",mouseOutHandler,false);
box.addEventListener("mouseover",mouseOverHandler,false);
}-*/;
К этому:
private native void addNativeMouseWheelListener(ValueBox instance, String id) /*-{
function mouseOverHandler(e) {
$wnd.addEventListener("DOMMouseScroll", scrollWheelMove, false);
}
function mouseOutHandler(e) {
$wnd.removeEventListener("DOMMouseScroll", scrollWheelMove, false);
}
function scrollWheelMove(e) {
if ($wnd.event || $wnd.Event) {
if (!e) e = $wnd.event;
if (e.wheelDelta <= 0 || e.detail > 0 ) {
$wnd.alert("DOWN");
} else {
instance.@com.proprintsgear.design_lab.client.ValueBox::increaseValue()();
}
instance.@com.proprintsgear.design_lab.client.ValueBox::fireChange()();
}
}
var box=$doc.getElementById(id);
box.addEventListener("mouseout",mouseOutHandler,false);
box.addEventListener("mouseover",mouseOverHandler,false);
}-*/;