在我过去完成的所有代码中,我从未使用“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 {
[email protected] /cdn-cgi/l/email-protection_lab.client.ValueBox::increaseValue()();
}
[email protected] /cdn-cgi/l/email-protection_lab.client.ValueBox::fireChange()();
}
}
var box=$doc.getElementById(id);
box.addEventListener("mouseout",mouseOutHandler,false);
box.addEventListener("mouseover",mouseOverHandler,false);
}-*/;
To this:
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 {
[email protected] /cdn-cgi/l/email-protection_lab.client.ValueBox::increaseValue()();
}
[email protected] /cdn-cgi/l/email-protection_lab.client.ValueBox::fireChange()();
}
}
var box=$doc.getElementById(id);
box.addEventListener("mouseout",mouseOutHandler,false);
box.addEventListener("mouseover",mouseOverHandler,false);
}-*/;