Esempio n. 1
0
  public void createKeyInputHandling() {
    scene.setOnKeyPressed(
        new EventHandler<KeyEvent>() {
          @Override
          public void handle(KeyEvent event) {
            switch (event.getCode()) {
              case UP:
                if (!input.inputKeys[KeyType.UpArrow.ordinal()].isPressed())
                  input.inputKeys[KeyType.UpArrow.ordinal()].setPressed();
                break;
              case DOWN:
                if (!input.inputKeys[KeyType.DownArrow.ordinal()].isPressed())
                  input.inputKeys[KeyType.DownArrow.ordinal()].setPressed();

                break;
              case LEFT:
                if (!input.inputKeys[KeyType.LeftArrow.ordinal()].isPressed())
                  input.inputKeys[KeyType.LeftArrow.ordinal()].setPressed();
                break;
              case RIGHT:
                if (!input.inputKeys[KeyType.RightArrow.ordinal()].isPressed())
                  input.inputKeys[KeyType.RightArrow.ordinal()].setPressed();
                break;
              case ENTER:
                if (!input.inputKeys[KeyType.Enter.ordinal()].isPressed())
                  input.inputKeys[KeyType.Enter.ordinal()].setPressed();
                break;
              default:
                break;
            }
          }
        });
    scene.setOnKeyReleased(
        new EventHandler<KeyEvent>() {

          @Override
          public void handle(KeyEvent event) {
            switch (event.getCode()) {
              case UP:
                input.inputKeys[KeyType.UpArrow.ordinal()].setReleased();
                break;
              case DOWN:
                input.inputKeys[KeyType.DownArrow.ordinal()].setReleased();
                break;
              case LEFT:
                input.inputKeys[KeyType.LeftArrow.ordinal()].setReleased();
                break;
              case RIGHT:
                input.inputKeys[KeyType.RightArrow.ordinal()].setReleased();
                break;
              case ENTER:
                input.inputKeys[KeyType.Enter.ordinal()].setReleased();
                break;
              default:
                break;
            }
          }
        });
  }
 @Inject
 public OverwriteConfirmationDialog(StylesConfig styles) {
   initModality(Modality.WINDOW_MODAL);
   initStyle(StageStyle.UTILITY);
   setResizable(false);
   BorderPane containerPane = new BorderPane();
   containerPane.getStyleClass().addAll(Style.CONTAINER.css());
   containerPane.getStyleClass().addAll("-pdfsam-dialog", "-pdfsam-warning-dialog");
   containerPane.setCenter(dialogContent);
   HBox buttons =
       new HBox(
           buildButton(DefaultI18nContext.getInstance().i18n("Overwrite"), true),
           buildButton(DefaultI18nContext.getInstance().i18n("Cancel"), false));
   buttons.getStyleClass().add("-pdfsam-dialog-buttons");
   containerPane.setBottom(buttons);
   Scene scene = new Scene(containerPane);
   scene.getStylesheets().addAll(styles.styles());
   scene.setOnKeyReleased(new HideOnEscapeHandler(this));
   setScene(scene);
 }