You can determine what closes the screen and prevent closing. The code below, checks that the screen is closing by main menu item, prevent closing and makes this screen active:
public class UserBrowse extends StandardLookup<User> {
@Autowired
private Screens screens;
@Subscribe
public void onBeforeClose(BeforeCloseEvent event) {
StandardCloseAction closeAction = ((StandardCloseAction) event.getCloseAction());
if ("mainMenu".equals(closeAction.getActionId())) {
event.preventWindowClose();
// Select a tab that contains this screen
Collection<WindowStack> workAreaStacks = screens.getOpenedScreens().getWorkAreaStacks();
for (WindowStack windowStack : workAreaStacks) {
if (windowStack.getBreadcrumbs().contains(this)) {
windowStack.select();
}
}
}
}
}