本文整理了Java中javafx.scene.input.KeyCode
类的一些代码示例,展示了KeyCode
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyCode
类的具体详情如下:
包路径:javafx.scene.input.KeyCode
类名称:KeyCode
暂无
代码示例来源:origin: pmd/pmd
.filter(key -> key.isControlDown() && key.getCode().equals(KeyCode.SPACE))
.map(searchPoint -> myCodeArea.getCaretPosition());
代码示例来源:origin: org.testfx/testfx-internal-java8
@SuppressWarnings("deprecated")
public static int convertToKeyCodeId(KeyCode keyCode) {
return keyCode.impl_getCode();
}
代码示例来源:origin: org.loadui/testFx
@SuppressWarnings("deprecation")
public static KeyCode findKeyCode(char character) {
if (KEY_CODES.containsKey(character)) {
return KEY_CODES.get(character);
}
KeyCode keyCode = KeyCode.getKeyCode(String.valueOf(Character.toUpperCase(character)));
if (keyCode != null) {
return keyCode;
}
for (KeyCode code : KeyCode.values()) {
if ((char) code.impl_getCode() == character) {
return code;
}
}
throw new IllegalArgumentException("No KeyCode found for character: " + character);
}
}
代码示例来源:origin: stackoverflow.com
public class KeysMapper {
private static HashMap<Character, Integer> charMap = new HashMap<Character, Integer>();
static {
for (KeyCode keyCode : KeyCode.values()) {
if (keyCode.impl_getCode() >= 65 && keyCode.impl_getCode() <= 90){
charMap.put(keyCode.getName().toLowerCase().toCharArray()[0], keyCode.impl_getCode());
}
else{
charMap.put(keyCode.getName().toLowerCase().toCharArray()[0], keyCode.impl_getCode());
}
}
}
public static Key charToKey(char c){
if(c>=65 && c<=90){
return new Key(charMap.get(c), true);
} else {
return new Key(charMap.get(c), false);
}
}
public static List<Key> stringToKeys(String text){
List<Key> keys = new ArrayList<Key>();
for (char c : text.toCharArray()) {
keys.add(charToKey(c));
}
return keys;
}
代码示例来源:origin: org.controlsfx/controlsfx
private <T> void keyPressed(KeyEvent event) {
KeyCode code = event.getCode();
if (code.isLetterKey() || code.isDigitKey() || code == KeyCode.SPACE) {
String letter = code.getChar();
if (event.getSource() instanceof ComboBox) {
ComboBox<T> comboBox = (ComboBox<T>) event.getSource();
T item = getEntryWithKey(letter, comboBox.getConverter(), comboBox.getItems(), comboBox);
if (item != null) {
comboBox.setValue(item);
}
} else if (event.getSource() instanceof ChoiceBox) {
ChoiceBox<T> choiceBox = (ChoiceBox<T>) event.getSource();
T item = getEntryWithKey(letter, choiceBox.getConverter(), choiceBox.getItems(), choiceBox);
if (item != null) {
choiceBox.setValue(item);
}
}
}
}
代码示例来源:origin: ch.sahits.game/OpenPatricianJavaFX
@Override
public void handle(KeyEvent event) {
if (event.getCode().equals(KeyCode.Q) && event.isControlDown()) {
event.consume();
Platform.exit();
}
}
代码示例来源:origin: org.loadui/testFx
@SuppressWarnings("deprecation")
@Override
public void pressNoWait( KeyCode key )
{
robot.keyPress( key.impl_getCode() );
}
代码示例来源:origin: org.testfx/testfx-legacy
@SuppressWarnings("deprecation")
public static KeyCode findKeyCode(char character) {
if (KEY_CODES.containsKey(character)) {
return KEY_CODES.get(character);
}
KeyCode keyCode = KeyCode.getKeyCode(String.valueOf(Character.toUpperCase(character)));
if (keyCode != null) {
return keyCode;
}
for (KeyCode code : KeyCode.values()) {
if ((char) code.impl_getCode() == character) {
return code;
}
}
throw new IllegalArgumentException("No KeyCode found for character: " + character);
}
}
代码示例来源:origin: brunoborges/webfx
fxView.setOnKeyPressed(e -> {
KeyCode keyCode = e.getCode();
if (keyCode.equals(KeyCode.F5) || (keyCode.equals(KeyCode.R) && e.isControlDown())) {
reload();
if (keyCode.equals(KeyCode.LEFT) && e.isControlDown()) {
goBack();
if (keyCode.equals(KeyCode.RIGHT) && e.isControlDown()) {
goForward();
if (keyCode.equals(KeyCode.Q) && e.isControlDown()) {
System.exit(0);
代码示例来源:origin: org.loadui/testFx
@SuppressWarnings("deprecation")
@Override
public void releaseNoWait( KeyCode key )
{
robot.keyRelease( key.impl_getCode() );
}
代码示例来源:origin: ch.sahits.game/OpenPatricianDisplay
@Override
public void handle(KeyEvent event) {
try {
if (event.getCode().equals(KeyCode.F10)) {
cheatModeActive = !cheatModeActive;
logger.debug("Toggle cheatmode. Cheat active: {}", cheatModeActive);
} else {
if (cheatModeActive && event.isControlDown()) {
if (event.getCode().equals(KeyCode.S)) {
logger.debug("Cheat created a new ship in " + city.getName());
if (event.getCode().equals(KeyCode.W)) {
if (event.getCode().equals(KeyCode.V)) {
debugOutputOn = !debugOutputOn;
List<String> loggerNames = getLoggerNames();
代码示例来源:origin: org.loadui/testFx
@SuppressWarnings("deprecation")
@Override
public void press( KeyCode key )
{
robot.keyPress( key.impl_getCode() );
FXTestUtils.awaitEvents();
}
代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-engine
public static String showConfirm(String title, String message, String... options) {
final Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.initStyle(StageStyle.UTILITY);
alert.setTitle("Choose an option");
alert.setHeaderText(title);
alert.setContentText(message);
// To make enter key press the actual focused button, not the first one.
// Just like pressing
// "space".
alert.getDialogPane().addEventFilter(KeyEvent.KEY_PRESSED, event -> {
if (event.getCode().equals(KeyCode.ENTER)) {
event.consume();
}
});
if (options == null || options.length == 0) {
options = new String[] {OK, CANCEL};
}
final List<ButtonType> buttons = new ArrayList<>();
for (final String option : options) {
buttons.add(new ButtonType(option));
}
alert.getButtonTypes().setAll(buttons);
final Optional<ButtonType> result = alert.showAndWait();
if (!result.isPresent()) {
return CANCEL;
} else {
return result.get().getText();
}
}
代码示例来源:origin: at.bestsolution.efxclipse.rt/org.eclipse.fx.ui.workbench.fx
@SuppressWarnings("deprecation")
static final int convertEventToModifiedAccelerator(final KeyEvent event) {
int modifiers = getStateMask(event) & FxKeyLookup.MODIFIER_MASK;
return modifiers + event.getCode().impl_getCode();
// char character = topKey(event);
// return modifiers + toUpperCase(character);
}
代码示例来源:origin: ch.sahits.game/OpenPatricianDisplay
});
EventHandler<KeyEvent> closeKeyHandler = event -> {
if (event.getCode().equals(KeyCode.ESCAPE)) {
Platform.runLater(() -> {
try {
代码示例来源:origin: org.loadui/testFx
@SuppressWarnings("deprecation")
@Override
public void release( KeyCode key )
{
robot.keyRelease( key.impl_getCode() );
FXTestUtils.awaitEvents();
}
代码示例来源:origin: com.uvic-cfar.swim/worldwind
/**
* Handles the key events to change the current planning time and
* planning time step duration.
*/
@Override
public void handle(KeyEvent event) {
if (KeyCode.RIGHT.equals(event.getCode())) {
if (event.isControlDown()) {
if (0 > this.duration.compareTo(DURATION_MAX)) {
this.duration = this.duration.plusMinutes(1);
}
} else {
this.picker.setLocalDateTime(this.picker.getLocalDateTime().plus(this.duration));
this.picker.getValueValidationCallback().call(this.picker.getLocalDateTime());
}
event.consume();
} else if (KeyCode.LEFT.equals(event.getCode())) {
if (event.isControlDown()) {
if (0 < this.duration.compareTo(Duration.ZERO)) {
this.duration = this.duration.minusMinutes(1);
}
} else {
this.picker.setLocalDateTime(this.picker.getLocalDateTime().minus(this.duration));
this.picker.getValueValidationCallback().call(this.picker.getLocalDateTime());
}
event.consume();
}
}
代码示例来源: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.controlsfx/controlsfx
@Override public void handle(KeyEvent event) {
if (KeyCode.TAB.equals(event.getCode())) {
if (lowThumb.isFocused()) {
if (event.isShiftDown()) {
lowThumb.setFocus(false);
new ParentTraversalEngine(
rangeSlider.getScene().getRoot(), algorithm)
.select(lowThumb, Direction.PREVIOUS)
.requestFocus();
} else {
lowThumb.setFocus(false);
highThumb.setFocus(true);
}
event.consume();
} else if (highThumb.isFocused()) {
if(event.isShiftDown()) {
highThumb.setFocus(false);
lowThumb.setFocus(true);
} else {
highThumb.setFocus(false);
new ParentTraversalEngine(
rangeSlider.getScene().getRoot(), algorithm)
.select(highThumb, Direction.NEXT)
.requestFocus();
}
event.consume();
}
}
}
};
代码示例来源:origin: org.processing/core
@SuppressWarnings("deprecation")
private int getKeyCode(KeyEvent fxEvent) {
if (fxEvent.getEventType() == KeyEvent.KEY_TYPED) {
return 0;
}
KeyCode kc = fxEvent.getCode();
switch (kc) {
case ALT_GRAPH:
return PConstants.ALT;
default:
break;
}
return kc.impl_getCode();
}
内容来源于网络,如有侵权,请联系作者删除!