Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

TUTORIALVaadin lets you build secure, UX-first PWAs entirely in Java.
Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Calling javascript synchronously by Enver Haase, 1 month ago
How to open Navigator.navigateTo in a new browser tab?
Hi,
I've a few locations in code where I'd like to allow users to open an UI in a new page - e.g. when the user presses "CTRL" when clicking on a MenuItem. Is it possible to query the system which keys are currently pressed?
The code
MenuItem ellipsis = bar.addItem("", FontAwesome.ELLIPSIS_V, null);
ellipsis.addItem("Search...", e -> {
Search query =...;
// if CTRL is not pressed, open view in the same browser tab:
getUI().getNavigator().navigateTo(computeView(query));
// else (CTRL is pressed), open a new tab and navigate there:
String url = ... + computeView(query));
getUI().getPage().open(url, "_blank");
});
Thanks,
Marcel
Last updated on
Most browsers require client side user event, like click event to be involved for opening with "_blank"
target, otherwise the browser will block it. Thus there are some limitations in this. E.g. in Vaadin8 BrowserWindowOpener has this implemented in client side.
Last updated on
You cannot reply to this thread.