I have a GWT widget representing a document print preview. In this widget the print button/action is managed by an external Chrome service. I need to detect the native window.onafterprint event from my jave code.
How can I do that?
Providing code with no success:
var popup = $wnd.open(url, title, ""); // this open the preview window
popup.onafterprint = function (ev) {
$wnd.console.log("mess 2"); // to try to see if detect the print button
}
One way to achieve this is to export a Java handler to Javascript, this way the Javascript event can call the Java handler:
public MyUtilityClass {
public static int handleOnAfterPrint(String message) { ... }
public static native void exportStaticMethod() /*-{
$wnd.handleOnAfterPrint =
$entry(@mypackage.MyUtilityClass::handleOnAfterPrint(Ljava/lang/String;));
}-*/;
}
So you can do:
popup.onafterprint = function (ev) {
handleOnAfterPrint("mess 2");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.