Java 类javafx.scene.input.InputEvent 实例源码

项目:performance-test-harness-for-geoevent    文件:OrchestratorController.java   
/**
 * 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();
        }
    }
}
项目:WellBehavedFX    文件:InputMapTest.java   
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);
}
项目:CalendarFX    文件:EntryViewBase.java   
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);
    }
}
项目:octoBubbles    文件:AbstractDiagramController.java   
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();
    });
}
项目:octoBubbles    文件:SketchController.java   
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;
    }
}
项目:octoBubbles    文件:SketchController.java   
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);
}
项目:OctoUML    文件:AbstractDiagramController.java   
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();
    });
}
项目:OctoUML    文件:SketchController.java   
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;
    }
}
项目:OctoUML    文件:SketchController.java   
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);
}
项目:FXImgurUploader    文件:TButtonSkin.java   
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();
            }
        }
    };
}
项目:Nocturne    文件:MainController.java   
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));
}
项目:drive-uploader    文件:MainMenuController.java   
@FXML
private void handleKeyInput(final InputEvent event) {
    if (event instanceof KeyEvent) {
        final KeyEvent keyEvent = (KeyEvent) event;
        if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.A) {
            showAboutDialog () ;
        }
    }
}
项目:ViPaint    文件:VimBar.java   
/**
 * 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();
                }
            });
}
项目:Enzo    文件:TButtonSkin.java   
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();
            }
        }
    };
}
项目:EC_GroupProj_CSC143    文件:MainWindowController.java   
/**
 * Handles keyboard input (in case we ever want to add keyboard shortcuts).
 */
@FXML
public void handleKeyboardInput(InputEvent event) {

}
项目:marathonv5    文件:JavaFxRecorderHook.java   
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);
}
项目:octoBubbles    文件:SketchController.java   
public void onTouchReleased(InputEvent event) {
    if(event instanceof TouchEvent) {
        currentSketches.remove(((TouchEvent) event).getTouchPoint().getId());
    }
}
项目:coaster    文件:InputManager.java   
private static void updateMousePosition(InputEvent e) {
    mouseX = ((MouseEvent) e).getX();
    mouseY = ((MouseEvent) e).getY();
}
项目:OctoUML    文件:SketchController.java   
public void onTouchReleased(InputEvent event) {
    if(event instanceof TouchEvent) {
        currentSketches.remove(((TouchEvent) event).getTouchPoint().getId());
    }
}
项目:openjfx-8u-dev-tests    文件:SceneInputApp.java   
@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();
}
项目:fx-experience    文件:OnScreenKeyEvent.java   
public OnScreenKeyEvent(EventType<? extends InputEvent> type) {
  super(type);
}
项目:jointry    文件:OnScreenKeyEvent.java   
public OnScreenKeyEvent(EventType<? extends InputEvent> type) {
    super(type);
}
项目:CalendarFX    文件:DateControl.java   
/**
 * 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;
}
项目:CalendarFX    文件:DateControl.java   
/**
 * 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;
}
项目:CalendarFX    文件:DateControl.java   
/**
 * 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;
}
项目:CalendarFX    文件:DateControl.java   
/**
 * 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);
}
项目:fx-experience    文件:OnScreenKeyEvent.java   
public OnScreenKeyEvent(KeyButton button, EventType<? extends InputEvent> type) {
  super(button, button, type);

}
项目:jointry    文件:OnScreenKeyEvent.java   
public OnScreenKeyEvent(KeyButton button, EventType<? extends InputEvent> type) {
    super(button, button, type);

}