本文整理了Java中javafx.scene.input.KeyEvent.getCode()
方法的一些代码示例,展示了KeyEvent.getCode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyEvent.getCode()
方法的具体详情如下:
包路径:javafx.scene.input.KeyEvent
类名称:KeyEvent
方法名:getCode
暂无
代码示例来源:origin: stackoverflow.com
textField.setOnKeyPressed(new EventHandler<KeyEvent>()
{
@Override
public void handle(KeyEvent ke)
{
if (ke.getCode().equals(KeyCode.ENTER))
{
doSomething();
}
}
});
代码示例来源:origin: jfoenixadmin/JFoenix
private void initNavigation() {
setOnKeyPressed(ke -> {
switch (ke.getCode()) {
case SPACE:
case ENTER:
// select the focused color
if (focusedSquare != null) {
focusedSquare.selectColor(ke);
}
ke.consume();
break;
default: // no-op
}
});
}
代码示例来源:origin: jfoenixadmin/JFoenix
private void createEditorNode() {
EventHandler<KeyEvent> keyEventsHandler = t -> {
if (t.getCode() == KeyCode.ENTER) {
commitHelper(false);
} else if (t.getCode() == KeyCode.ESCAPE) {
cancelEdit();
} else if (t.getCode() == KeyCode.TAB) {
commitHelper(false);
editNext(!t.isShiftDown());
}
};
ChangeListener<Boolean> focusChangeListener = (observable, oldValue, newValue) -> {
//This focus listener fires at the end of cell editing when focus is lost
//and when enter is pressed (because that causes the text field to lose focus).
//The problem is that if enter is pressed then cancelEdit is called before this
//listener runs and therefore the text field has been cleaned up. If the
//text field is null we don't commit the edit. This has the useful side effect
//of stopping the double commit.
if (editorNode != null && !newValue) {
commitHelper(true);
}
};
editorNode = builder.createNode(getValue(), keyEventsHandler, focusChangeListener);
}
代码示例来源:origin: pmd/pmd
e.getEventType().equals(KeyEvent.KEY_RELEASED) && e.getCode() == KeyCode.ENTER
|| e.getEventType().equals(KeyEvent.KEY_PRESSED) && e.getCode() == KeyCode.TAB
.filter(key -> key.isControlDown() && key.getCode().equals(KeyCode.SPACE))
.map(searchPoint -> myCodeArea.getCaretPosition());
代码示例来源:origin: jfoenixadmin/JFoenix
editor.setWrapText(true);
editor.addEventFilter(KeyEvent.KEY_RELEASED, event -> {
if (event.getCode() != KeyCode.ENTER) {
getSkinnable().pseudoClassStateChanged(PSEUDO_CLASS_ERROR, false);
switch (event.getCode()) {
case ENTER:
if (!editor.getText().trim().isEmpty()) {
switch (ke.getCode()) {
case ESCAPE:
case F10:
代码示例来源:origin: jfoenixadmin/JFoenix
private void registerEventListener() {
suggestionList.setOnMouseClicked(me -> {
if (me.getButton() == MouseButton.PRIMARY) {
selectItem();
getSkinnable().hide();
}
});
control.showingProperty().addListener((o, oldVal, newVal) -> {
if (newVal) {
animate();
}
});
suggestionList.setOnKeyPressed(event -> {
switch (event.getCode()) {
case ENTER:
selectItem();
getSkinnable().hide();
break;
case ESCAPE:
getSkinnable().hide();
break;
default:
break;
}
});
}
代码示例来源:origin: jfoenixadmin/JFoenix
if (keyEvent.getCode() == KeyCode.ESCAPE) {
if (!isHideOnEscape()) {
keyEvent.consume();
代码示例来源:origin: jfoenixadmin/JFoenix
switch (key.getCode()) {
case ESCAPE:
close();
代码示例来源:origin: jfoenixadmin/JFoenix
switch (event.getCode()) {
case HOME:
代码示例来源:origin: stackoverflow.com
@FXML
public void buttonPressed(KeyEvent e)
{
if(e.getCode().toString().equals("ENTER"))
{
//do something
}
}
代码示例来源:origin: stackoverflow.com
@FXML
public void handleEnterPressed(KeyEvent event)
if (event.getCode() == KeyCode.ENTER) {
// do some actions
}
}
代码示例来源:origin: stackoverflow.com
scene.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent evt) {
if (evt.getCode().equals(KeyCode.ESCAPE)) {
stage.close();
}
}
});
代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.ui.workbench.fx
private static boolean isModifierKey(KeyEvent event) {
switch (event.getCode()) {
case ALT:
case CONTROL:
case SHIFT:
case COMMAND:
return true;
default:
return false;
}
}
代码示例来源:origin: torakiki/pdfsam
if (event.getCode() == KeyCode.ESCAPE) {
textField.setText(converter.toString(getItem()));
cancelEdit();
event.consume();
} else if (event.getCode() == KeyCode.RIGHT) {
getTableView().getSelectionModel().selectRightCell();
event.consume();
} else if (event.getCode() == KeyCode.LEFT) {
getTableView().getSelectionModel().selectLeftCell();
event.consume();
} else if (event.getCode() == KeyCode.UP) {
getTableView().getSelectionModel().selectAboveCell();
event.consume();
} else if (event.getCode() == KeyCode.DOWN) {
getTableView().getSelectionModel().selectBelowCell();
event.consume();
代码示例来源:origin: org.jrebirth.af/core
/**
* Return the forbidden key checker callback (black-list).
*
* Check if the key event does NOT concern a KeyCode provided. the current key triggered is NOT into provided list
*
* @return the forbidden callback
*/
default Callback<KeyEvent, Boolean> forbiddenKeys(final KeyCode... codes) {
return event -> !Stream.of(codes).anyMatch(kc -> kc == event.getCode());
}
代码示例来源:origin: org.jrebirth.af/core
/**
* Return the allowed key checker callback (white-list).
*
* Check if the key event concerns a KeyCode provided. true if the current key triggered is into provided list
*
* @return the allowed callback
*/
default Callback<KeyEvent, Boolean> allowedKeys(final KeyCode... codes) {
return event -> Stream.of(codes).anyMatch(kc -> kc == event.getCode());
}
代码示例来源:origin: stackoverflow.com
scene.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>
() {
@Override
public void handle(KeyEvent t) {
if(t.getCode()==KeyCode.ESCAPE)
{
System.out.println("click on escape");
Stage sb = (Stage)label.getScene().getWindow();//use any one object
sb.close();
}
}
});
代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.ui.workbench.fx
@SuppressWarnings("deprecation")
static int convertEventToUnmodifiedAccelerator(KeyEvent event) {
int modifiers = getStateMask(event) & FxKeyLookup.MODIFIER_MASK;
return modifiers + event.getCode().impl_getCode();
}
代码示例来源:origin: org.copper-engine/copper-monitoring-client
@Override
public void handle(KeyEvent event) {
if (event.getCode() == KeyCode.ENTER) {
if (!startButton.isDisabled()) {
startButton.fire();
}
}
}
};
代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-engine
private void registerListener() {
addEventFilter(KeyEvent.KEY_RELEASED, key -> {
if (key.getCode() == KeyCode.ESCAPE) {
if (proposalListPopup.isShowing()) {
proposalListPopup.hide();
}
}
});
}
内容来源于网络,如有侵权,请联系作者删除!