Reputation: 3018
I'm using javafx's webengine to display a web page. And on the page, there's script calling window.confirm. I already know how to set the confirm handler and how to show a modal-like dialog.
My question is how can I get the user's choice before handler returns?
webEngine.setConfirmHandler(new Callback<String, Boolean>() {
@Override
public Boolean call(String message) {
// Show the dialog
...
return true; // How can I get user's choice here?
}
});
Upvotes: 1
Views: 1283
Reputation: 3018
As described in javafx-jira.kenai.com/browse/RT-19783, we can use the new method showAndWait which is available in JavaFx 2.2 to achieve this.
Stage class:
/** * Show the stage and wait for it to be closed before returning to the * caller. This must be called on the FX Application thread. The stage * must not already be visible prior to calling this method. This must not * be called on the primary stage. * * @throws IllegalStateException if this method is called on a thread * other than the JavaFX Application Thread. * @throws IllegalStateException if this method is called on the * primary stage. * @throws IllegalStateException if this stage is already showing. */ public void showAndWait();
@jewelsea created a sample on https://gist.github.com/2992072. Thanks!
Upvotes: 3