示例#1
0
 @Override
 protected void afterLeaveFocus(FocusChangeDirection direction, Interactable nextInFocus) {
   if (popupWindow != null) {
     popupWindow.close();
     popupWindow = null;
   }
 }
示例#2
0
  private Result handleReadOnlyCBKeyStroke(KeyStroke keyStroke) {
    switch (keyStroke.getKeyType()) {
      case ArrowDown:
        if (popupWindow != null) {
          popupWindow.listBox.handleKeyStroke(keyStroke);
          return Result.HANDLED;
        }
        return Result.MOVE_FOCUS_DOWN;

      case ArrowUp:
        if (popupWindow != null) {
          popupWindow.listBox.handleKeyStroke(keyStroke);
          return Result.HANDLED;
        }
        return Result.MOVE_FOCUS_UP;

      case Enter:
        if (popupWindow != null) {
          popupWindow.listBox.handleKeyStroke(keyStroke);
          popupWindow.close();
          popupWindow = null;
        } else {
          popupWindow = new PopupWindow();
          popupWindow.setPosition(toGlobal(getPosition().withRelativeRow(1)));
          ((WindowBasedTextGUI) getTextGUI()).addWindow(popupWindow);
        }
        break;

      case Escape:
        if (popupWindow != null) {
          popupWindow.close();
          popupWindow = null;
          return Result.HANDLED;
        }
        break;

      default:
    }
    return super.handleKeyStroke(keyStroke);
  }