boolean () { MenuSelectionManager menuSelectionManager = MenuSelectionManager.defaultManager(); MenuElement[] selectedPath = menuSelectionManager.getSelectedPath(); if (selectedPath.length > 0) { // hide popup menu if any menuSelectionManager.clearSelectedPath(); } else { if (ApplicationManager.getApplication() == null) { return false; } final StackingPopupDispatcher popupDispatcher = StackingPopupDispatcher.getInstance(); if (popupDispatcher != null && !popupDispatcher.isPopupFocused()) { return false; } } return true; }