在我过去所做的所有代码中,我从未使用'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); }-*/;