/** * Handle action related to input (in this case specifically only responds * to keyboard event CTRL-A). * * @param event Input event. */ @FXML public void handleKeyInput(final InputEvent event) { if (event instanceof KeyEvent) { final KeyEvent keyEvent = (KeyEvent) event; if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.A) { provideAboutFunctionality(); } else if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.R) { showReportOptionsDialog(); } else if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.O) { openFixturesFile(); } else if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.S) { saveFixturesFile(); } else if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.L) { showLoggerDialog(); } } }
public void justKidding() { Node node = new Region(); InputMap<InputEvent> im = sequence( consume(keyPressed(UP), e -> moveUp()), consume(keyPressed(DOWN), e -> moveDown()), consume(keyPressed(LEFT), e -> moveLeft()), consume(keyPressed(RIGHT), e -> moveRight()), consume( mouseMoved().onlyIf(MouseEvent::isPrimaryButtonDown), e -> move(e.getX(), e.getY()))); Nodes.addFallbackInputMap(node, im); Nodes.removeInputMap(node, im); }
private void showDetails(InputEvent evt, double x, double y) { DateControl control = getDateControl(); /* * We might run in the sampler application. Then the entry view will not * be inside a date control. */ if (control != null && getParent() != null) { Callback<EntryDetailsParameter, Boolean> callback = control.getEntryDetailsCallback(); EntryDetailsParameter param = new EntryDetailsParameter(evt, control, getEntry(), getParent(), x, y); callback.call(param); } }
private void initDrawPaneActions() { //Makes sure the pane doesn't scroll when using a touch screen. drawPane.setOnScroll(event -> event.consume()); //Controls the look of the cursor, we only want the default look drawPane.addEventHandler(InputEvent.ANY, mouseEvent -> { getStage().getScene().setCursor(Cursor.DEFAULT); mouseEvent.consume(); }); }
public void onTouchPressed(InputEvent event) { Sketch sketch = new Sketch(); mController.addSketch(sketch, false, false); double x, y; if(event instanceof TouchEvent){ x = ((TouchEvent) event).getTouchPoint().getX(); y = ((TouchEvent) event).getTouchPoint().getY(); } else { //event instanceof mouseevent x = ((MouseEvent)event).getX(); y = ((MouseEvent)event).getY(); } double xPoint; double yPoint; if(event.getSource() instanceof AbstractNodeView){ xPoint = ((AbstractNodeView)event.getSource()).getTranslateX() + x; yPoint = ((AbstractNodeView)event.getSource()).getTranslateY() + y; } else { xPoint = x; yPoint = y; } sketch.setColor(color); sketch.setStart(xPoint, yPoint); if(event instanceof TouchEvent) { currentSketches.put(((TouchEvent)event).getTouchPoint().getId(), sketch); } else { //event instanceof mouseevent currentSketch = sketch; } }
public void onTouchMoved(InputEvent event) { Sketch sketch; double xPoint; double yPoint; if(event instanceof TouchEvent){ sketch = currentSketches.get(((TouchEvent)event).getTouchPoint().getId()); if(event.getSource() instanceof AbstractNodeView){ xPoint = ((AbstractNodeView)event.getSource()).getTranslateX() + ((TouchEvent)event).getTouchPoint().getX(); yPoint = ((AbstractNodeView)event.getSource()).getTranslateY() + ((TouchEvent)event).getTouchPoint().getY(); } else { xPoint = ((TouchEvent)event).getTouchPoint().getX(); yPoint = ((TouchEvent)event).getTouchPoint().getY(); } } else { //event instanceof mouseevent sketch = currentSketch; if(event.getSource() instanceof AbstractNodeView){ xPoint = ((AbstractNodeView)event.getSource()).getTranslateX() + ((MouseEvent)event).getX(); yPoint = ((AbstractNodeView)event.getSource()).getTranslateY() + ((MouseEvent)event).getY(); } else { xPoint = ((MouseEvent)event).getX(); yPoint = ((MouseEvent)event).getY(); } } sketch.addPoint(xPoint, yPoint); }
private void init() { if (Double.compare(getSkinnable().getPrefWidth(), 0.0) <= 0 || Double.compare(getSkinnable().getPrefHeight(), 0.0) <= 0 || Double.compare(getSkinnable().getWidth(), 0.0) <= 0 || Double.compare(getSkinnable().getHeight(), 0.0) <= 0) { if (getSkinnable().getPrefWidth() > 0 && getSkinnable().getPrefHeight() > 0) { getSkinnable().setPrefSize(getSkinnable().getPrefWidth(), getSkinnable().getPrefHeight()); } else { getSkinnable().setPrefSize(PREFERRED_SIZE, PREFERRED_SIZE); } } if (Double.compare(getSkinnable().getMinWidth(), 0.0) <= 0 || Double.compare(getSkinnable().getMinHeight(), 0.0) <= 0) { getSkinnable().setMinSize(MINIMUM_SIZE, MINIMUM_SIZE); } if (Double.compare(getSkinnable().getMaxWidth(), 0.0) <= 0 || Double.compare(getSkinnable().getMaxHeight(), 0.0) <= 0) { getSkinnable().setMaxSize(MAXIMUM_SIZE, MAXIMUM_SIZE); } inputHandler = new EventHandler<InputEvent>() { @Override public void handle(final InputEvent EVENT) { final EventType TYPE = EVENT.getEventType(); final Object SRC = EVENT.getSource(); if (MouseEvent.MOUSE_PRESSED == TYPE) { if (SRC.equals(on)) { getSkinnable().setSelected(false); } else if (SRC.equals(off)) { getSkinnable().setSelected(true); } EVENT.consume(); } } }; }
private void initTreeViews() { BiConsumer<InputEvent, TreeView<String>> clickHandler = (event, treeView) -> { if ((event instanceof MouseEvent && ((MouseEvent) event).getClickCount() == 2) || (event instanceof KeyEvent && ((KeyEvent) event).getCode() == KeyCode.ENTER)) { TreeItem<String> selected = treeView.getSelectionModel().getSelectedItem(); if (selected == null) { return; } if (selected.getChildren().isEmpty()) { String className = ((IdentifiableTreeItem) selected).getId().substring(1); if (Main.getLoadedJar() != null) { openTab(className, selected.getValue()); } } else { if (event instanceof MouseEvent == selected.isExpanded()) { selected.setExpanded(true); while (selected.getChildren().size() == 1) { selected = selected.getChildren().get(0); selected.setExpanded(true); } } else { selected.setExpanded(false); } } } }; obfTree.setOnMouseClicked(event -> clickHandler.accept(event, obfTree)); deobfTree.setOnMouseClicked(event -> clickHandler.accept(event, deobfTree)); obfTree.setOnKeyReleased(event -> clickHandler.accept(event, obfTree)); deobfTree.setOnKeyReleased(event -> clickHandler.accept(event, deobfTree)); }
@FXML private void handleKeyInput(final InputEvent event) { if (event instanceof KeyEvent) { final KeyEvent keyEvent = (KeyEvent) event; if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.A) { showAboutDialog () ; } } }
/** * Creates a vimbar */ public VimBar() { super(); this.setOnAction(e -> { String text = this.getText(); if(text.charAt(0) == ':') { text = text.substring(1); } commandManager.parseCommand(text); disable(); }); this.addEventHandler(KeyEvent.KEY_PRESSED, (event) -> { if (event.getCode() == KeyCode.ESCAPE) { disable(); } else if (event.getCode() == KeyCode.UP) { setText(":" + commandManager.getPrevious()); //positionCaret(getText().length()); // a weird workaround, positionCaret dosent work. Platform.runLater(() -> positionCaret(getText().length())); } else if (event.getCode() == KeyCode.DOWN) { setText(":" + commandManager.getNext()); //positionCaret(getText().length()); // a weird workaround, positionCaret dosent work. Platform.runLater(() -> positionCaret(getText().length())); } }); this.addEventHandler(InputEvent.ANY, (event) -> { if(getText().length() <= 0 || getText().charAt(0) != ':') { disable(); } }); }
/** * Handles keyboard input (in case we ever want to add keyboard shortcuts). */ @FXML public void handleKeyboardInput(InputEvent event) { }
private void removeEventFilter(Stage stage) { stage.getScene().getRoot().removeEventFilter(InputEvent.ANY, JavaFxRecorderHook.this); stage.getScene().getRoot().removeEventFilter(fileChooserEventType, JavaFxRecorderHook.this); stage.getScene().getRoot().removeEventFilter(folderChooserEventType, JavaFxRecorderHook.this); }
public void onTouchReleased(InputEvent event) { if(event instanceof TouchEvent) { currentSketches.remove(((TouchEvent) event).getTouchPoint().getId()); } }
private static void updateMousePosition(InputEvent e) { mouseX = ((MouseEvent) e).getX(); mouseY = ((MouseEvent) e).getY(); }
@Override public void start(Stage stage) { VBox vb = new VBox(); Scene scene = new Scene(vb); stage.setScene(scene); stage.setWidth(500); stage.setHeight(480); Pane p = new Pane(); p.setTranslateX(75); p.setTranslateY(75); final Text strOutput = new Text(); strOutput.setId("strOutput"); MyTextInput mti = new MyTextInput(); mti.setId("inputfield"); TextInputControl www = new TextField("bwbeb"); for (ConditionalFeature c : ConditionalFeature.values()) { System.out.println(c); } EventHandler<? super InputEvent> qqq = new EventHandler<InputEvent>() { public void handle(InputEvent e) { System.out.println("*"); //strOutput.setText("ok"); // let it be here for debug } }; EventHandler<? super InputMethodEvent> qqq2 = new EventHandler<InputMethodEvent>() { public void handle(InputMethodEvent t) { strOutput.setText("ok"); // TODO: test all these getters listed below. // "setOnInputMethodTextChanged" does not work now (see http://javafx-jira.kenai.com/browse/RT-12915), // and exact values returned by getters are not documented in details, so, // this test should be improved and expanded after RT-12915 fix. int caretPosition = t.getCaretPosition(); String committedString = t.getCommitted(); String strRepresentation = t.toString(); ObservableList<InputMethodTextRun> lstRun =t.getComposed(); for (InputMethodTextRun run: lstRun) { String runText = run.getText(); String runString = run.toString(); InputMethodHighlight imh = run.getHighlight(); InputMethodHighlight imh1 = InputMethodHighlight.SELECTED_RAW; InputMethodHighlight imh2 = InputMethodHighlight.valueOf("SELECTED_RAW"); } } }; mti.setOnInputMethodTextChanged(qqq2); mti.setOnKeyTyped(qqq); www.setOnInputMethodTextChanged(qqq2); www.setOnKeyTyped(qqq); vb.getChildren().add(mti); vb.getChildren().add(www); vb.getChildren().add(strOutput); stage.show(); }
public OnScreenKeyEvent(EventType<? extends InputEvent> type) { super(type); }
/** * Constructs a new parameter object. * * @param inputEvent the input event that triggered the need for showing entry * details (e.g. a mouse double click, or a context menu item * selection) * @param control the control where the event occurred * @param owner a node that can be used as an owner for the dialog or * popover * @param screenX the screen location where the event occurred * @param screenY the screen location where the event occurred */ public DetailsParameter(InputEvent inputEvent, DateControl control, Node owner, double screenX, double screenY) { this.inputEvent = inputEvent; this.dateControl = requireNonNull(control); this.owner = requireNonNull(owner); this.screenX = screenX; this.screenY = screenY; }
/** * The input event that triggered the need for showing entry details * (e.g. a mouse double click or a context menu item selection). * * @return the input event */ public InputEvent getInputEvent() { return inputEvent; }
/** * Constructs a new parameter object. * * @param inputEvent the input event that triggered the need for showing entry * details (e.g. a mouse double click, or a context menu item * selection) * @param control the control where the event occurred * @param entry the entry for which details are requested * @param owner a node that can be used as an owner for the dialog or * popover * @param screenX the screen location where the event occurred * @param screenY the screen location where the event occurred */ public EntryDetailsParameter(InputEvent inputEvent, DateControl control, Entry<?> entry, Node owner, double screenX, double screenY) { super(inputEvent, control, owner, screenX, screenY); this.entry = entry; }
/** * Constructs a new parameter object. * * @param inputEvent the input event that triggered the need for showing entry * details (e.g. a mouse double click, or a context menu item * selection) * @param control the control where the event occurred * @param date the date for which details are required * @param owner a node that can be used as an owner for the dialog or * popover * @param screenX the screen location where the event occurred * @param screenY the screen location where the event occurred */ public DateDetailsParameter(InputEvent inputEvent, DateControl control, Node owner, LocalDate date, double screenX, double screenY) { super(inputEvent, control, owner, screenX, screenY); this.localDate = requireNonNull(date); }
public OnScreenKeyEvent(KeyButton button, EventType<? extends InputEvent> type) { super(button, button, type); }