当前位置: 首页>>代码示例>>Java>>正文


Java InputEvent类代码示例

本文整理汇总了Java中javafx.scene.input.InputEvent的典型用法代码示例。如果您正苦于以下问题:Java InputEvent类的具体用法?Java InputEvent怎么用?Java InputEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


InputEvent类属于javafx.scene.input包,在下文中一共展示了InputEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleKeyInput

import javafx.scene.input.InputEvent; //导入依赖的package包/类
/**
 * 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();
        }
    }
}
 
开发者ID:Esri,项目名称:performance-test-harness-for-geoevent,代码行数:24,代码来源:OrchestratorController.java

示例2: justKidding

import javafx.scene.input.InputEvent; //导入依赖的package包/类
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);
}
 
开发者ID:FXMisc,项目名称:WellBehavedFX,代码行数:17,代码来源:InputMapTest.java

示例3: showDetails

import javafx.scene.input.InputEvent; //导入依赖的package包/类
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);
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:14,代码来源:EntryViewBase.java

示例4: initDrawPaneActions

import javafx.scene.input.InputEvent; //导入依赖的package包/类
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();
    });
}
 
开发者ID:kaanburaksener,项目名称:octoBubbles,代码行数:11,代码来源:AbstractDiagramController.java

示例5: onTouchPressed

import javafx.scene.input.InputEvent; //导入依赖的package包/类
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;
    }
}
 
开发者ID:kaanburaksener,项目名称:octoBubbles,代码行数:32,代码来源:SketchController.java

示例6: onTouchMoved

import javafx.scene.input.InputEvent; //导入依赖的package包/类
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);
}
 
开发者ID:kaanburaksener,项目名称:octoBubbles,代码行数:30,代码来源:SketchController.java

示例7: init

import javafx.scene.input.InputEvent; //导入依赖的package包/类
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();
            }
        }
    };
}
 
开发者ID:Simego,项目名称:FXImgurUploader,代码行数:34,代码来源:TButtonSkin.java

示例8: initTreeViews

import javafx.scene.input.InputEvent; //导入依赖的package包/类
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));
}
 
开发者ID:LapisBlue,项目名称:Nocturne,代码行数:35,代码来源:MainController.java

示例9: handleKeyInput

import javafx.scene.input.InputEvent; //导入依赖的package包/类
@FXML
private void handleKeyInput(final InputEvent event) {
	if (event instanceof KeyEvent) {
		final KeyEvent keyEvent = (KeyEvent) event;
		if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.A) {
			showAboutDialog () ;
		}
	}
}
 
开发者ID:roikku,项目名称:drive-uploader,代码行数:10,代码来源:MainMenuController.java

示例10: VimBar

import javafx.scene.input.InputEvent; //导入依赖的package包/类
/**
 * 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();
                }
            });
}
 
开发者ID:jgkamat,项目名称:ViPaint,代码行数:41,代码来源:VimBar.java

示例11: handleKeyboardInput

import javafx.scene.input.InputEvent; //导入依赖的package包/类
/**
 * Handles keyboard input (in case we ever want to add keyboard shortcuts).
 */
@FXML
public void handleKeyboardInput(InputEvent event) {

}
 
开发者ID:RyanCPeters,项目名称:EC_GroupProj_CSC143,代码行数:8,代码来源:MainWindowController.java

示例12: removeEventFilter

import javafx.scene.input.InputEvent; //导入依赖的package包/类
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);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:6,代码来源:JavaFxRecorderHook.java

示例13: onTouchReleased

import javafx.scene.input.InputEvent; //导入依赖的package包/类
public void onTouchReleased(InputEvent event) {
    if(event instanceof TouchEvent) {
        currentSketches.remove(((TouchEvent) event).getTouchPoint().getId());
    }
}
 
开发者ID:kaanburaksener,项目名称:octoBubbles,代码行数:6,代码来源:SketchController.java

示例14: updateMousePosition

import javafx.scene.input.InputEvent; //导入依赖的package包/类
private static void updateMousePosition(InputEvent e) {
	mouseX = ((MouseEvent) e).getX();
	mouseY = ((MouseEvent) e).getY();
}
 
开发者ID:UQdeco2800,项目名称:coaster,代码行数:5,代码来源:InputManager.java

示例15: start

import javafx.scene.input.InputEvent; //导入依赖的package包/类
@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();
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:67,代码来源:SceneInputApp.java


注:本文中的javafx.scene.input.InputEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。