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


Java KeyCode.ESCAPE属性代码示例

本文整理汇总了Java中javafx.scene.input.KeyCode.ESCAPE属性的典型用法代码示例。如果您正苦于以下问题:Java KeyCode.ESCAPE属性的具体用法?Java KeyCode.ESCAPE怎么用?Java KeyCode.ESCAPE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javafx.scene.input.KeyCode的用法示例。


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

示例1: onKeyPressed

private void onKeyPressed(KeyEvent event) {
    if (event.getCode() == KeyCode.ESCAPE) {
        handleSelection(Selection.CANCEL);
    } else if (event.getCode() == KeyCode.ENTER) {
        Node focusOwner = root.getScene().getFocusOwner();
        if (focusOwner instanceof Button) {
            ((Button) (focusOwner)).fire();
        }
    }
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:10,代码来源:SaveDialogComponent.java

示例2: handleOnKeyPressed

private void handleOnKeyPressed(KeyEvent keyEvent) {
    KeyCode code = keyEvent.getCode();
    if (!keyEvent.isMetaDown()) {
        String filterValue = filter.get();
        //log.debug("Handling KeyCode = " + code);
        if (code.isLetterKey() || code.isDigitKey() || code == KeyCode.MINUS) {
            filterValue += keyEvent.getText();
        } else if ((code == KeyCode.BACK_SPACE) && (filterValue.length() > 0)) {
            filterValue = filterValue.substring(0, filterValue.length() - 1);
        } else if (code == KeyCode.ESCAPE) {
            filterValue = EMPTY;
        } else if ((code == KeyCode.DOWN) || (code == KeyCode.UP)) {
            comboBox.show();
        }
        filter.set(filterValue);
        comboBox.getTooltip().textProperty().set(filterValue);
    }
}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:18,代码来源:FilteredComboBoxDecorator.java

示例3: handle

@Override
public void handle(KeyEvent event) {

    TextField editor = comboBox.getEditor();
    String text = editor.getText();

    if (event.getCode() == KeyCode.RIGHT
            || event.getCode() == KeyCode.LEFT
            || event.isControlDown()
            || event.getCode() == KeyCode.HOME
            || event.getCode() == KeyCode.END
            || event.getCode() == KeyCode.TAB) {
        return;
    }
    else if(event.getCode() == KeyCode.UP) {
        caretPos = -1;
        moveCaret(text.length());
        return;
    }
    else if(event.getCode() == KeyCode.DOWN) {
        if(!comboBox.isShowing()) {
            comboBox.show();
        }
        caretPos = -1;
        moveCaret(text.length());
        return;
    }
    else if(event.getCode() == KeyCode.BACK_SPACE) {
        moveCaretToPos = true;
        caretPos = editor.getCaretPosition();
    }
    else if(event.getCode() == KeyCode.DELETE) {
        moveCaretToPos = true;
        caretPos = editor.getCaretPosition();
    }

    String upperCaseText = text.toUpperCase();
    ObservableList<T> list = FXCollections.observableArrayList(data.stream()
            .filter(s -> transform.apply(s).toUpperCase().startsWith(upperCaseText))
            .collect(Collectors.toList()));

    comboBox.setItems(list);

    if (event.getCode() == KeyCode.ENTER
            || event.getCode() == KeyCode.ESCAPE) {
        if (!list.isEmpty()) {
            comboBox.getEditor().setText(transform.apply(list.get(0)));
            comboBox.getSelectionModel().select(0);
            comboBox.hide();
        }
        else {
            comboBox.getEditor().setText(text);
        }

    }
    else {
        comboBox.getEditor().setText(text);
        if(!moveCaretToPos) {
            caretPos = -1;
        }
        moveCaret(text.length());
        if(!list.isEmpty()) {
            comboBox.show();
        }
    }

}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:67,代码来源:AutoCompleteComboBoxListener.java

示例4: processKey

/**
 * Process key.
 *
 * @param event the event
 */
@FXThread
protected void processKey(@NotNull final KeyEvent event) {
    event.consume();
    if (event.getCode() == KeyCode.ESCAPE) {
        hide();
    }
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:12,代码来源:EditorDialog.java

示例5: needManualRecording

private boolean needManualRecording(KeyCode keyCode) {
    return keyCode == KeyCode.BACK_SPACE || keyCode == KeyCode.DELETE || keyCode == KeyCode.ESCAPE || keyCode == KeyCode.SPACE;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:3,代码来源:WSRecorder.java

示例6: handleKeyPress

/**
 * Handles ending of path creation using the escape key
 *
 * @param e
 * @param container
 * @param sprite
 */
private void handleKeyPress (KeyEvent e, Pane container, ISprite sprite) {
    if (e.getCode() == KeyCode.ESCAPE) {
        pathCreator.endPath(container);
        sprite.getMovementStrategy().setPath(pathCreator.getPathPoints());
    }
}
 
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:13,代码来源:SpriteController.java


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