本文整理汇总了Java中javafx.scene.input.KeyEvent.isControlDown方法的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.isControlDown方法的具体用法?Java KeyEvent.isControlDown怎么用?Java KeyEvent.isControlDown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.input.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.isControlDown方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ketEventGetModifiersExText
import javafx.scene.input.KeyEvent; //导入方法依赖的package包/类
public static String ketEventGetModifiersExText(KeyEvent event) {
StringBuffer sb = new StringBuffer();
if (event.isControlDown()) {
sb.append("Ctrl+");
}
if (event.isMetaDown()) {
sb.append("Meta+");
}
if (event.isAltDown()) {
sb.append("Alt+");
}
if (event.isShiftDown()) {
sb.append("Shift+");
}
String text = sb.toString();
if (text.equals("")) {
return text;
}
return text.substring(0, text.length() - 1);
}
示例2: checkModifier
import javafx.scene.input.KeyEvent; //导入方法依赖的package包/类
private static String checkModifier(KeyEvent e) {
String s = "";
if (e.isShiftDown()) {
s = "Shift";
}
if (e.isControlDown()) {
s = "Ctrl";
}
if (e.isAltDown()) {
s = "Alt";
}
if (e.isMetaDown()) {
s = "Meta";
}
return s;
}
示例3: buildModifiersText
import javafx.scene.input.KeyEvent; //导入方法依赖的package包/类
private String buildModifiersText(KeyEvent e) {
StringBuilder sb = new StringBuilder();
if (e.isAltDown()) {
sb.append("Alt+");
}
if (e.isControlDown()) {
sb.append("Ctrl+");
}
if (e.isMetaDown()) {
sb.append("Meta+");
}
if (e.isShiftDown()) {
sb.append("Shift+");
}
if (sb.length() > 0) {
sb.setLength(sb.length() - 1);
}
String mtext = sb.toString();
return mtext;
}
示例4: onMessageBoxKeyPressed
import javafx.scene.input.KeyEvent; //导入方法依赖的package包/类
@FXML
private void onMessageBoxKeyPressed(KeyEvent event) {
if(KeyCode.ENTER.equals(event.getCode())) {
if (((settings.getControlEnterToSendMessage() && event.isControlDown())
|| (!settings.getControlEnterToSendMessage() && !event.isShiftDown()))
&& !messageBox.getText().isEmpty()) {
Room room = client.getSelectedRoom();
if(room != null) {
try {
room.sendMessage(messageBox.getText());
} catch(SdkException e) {
System.out.printf("SdkException when trying to send a message: %s\n", e);
}
}
messageBox.clear();
event.consume();
} else if(event.isShiftDown()) {
messageBox.insertText(
messageBox.getCaretPosition(),
"\n"
);
}
}
}
示例5: recordRawKeyEvent
import javafx.scene.input.KeyEvent; //导入方法依赖的package包/类
@Override public void recordRawKeyEvent(RFXComponent r, KeyEvent e) {
JSONObject event = new JSONObject();
event.put("type", "key_raw");
KeyCode keyCode = e.getCode();
if (keyCode.isModifierKey()) {
return;
}
if ((keyCode.isFunctionKey() || keyCode.isArrowKey() || keyCode.isKeypadKey() || keyCode.isMediaKey()
|| keyCode.isNavigationKey() || e.isControlDown() || e.isMetaDown() || e.isAltDown()
|| needManualRecording(keyCode)) && e.getEventType() == KeyEvent.KEY_PRESSED) {
String mtext = buildModifiersText(e);
event.put("modifiersEx", mtext);
KeysMap keysMap = KeysMap.findMap(e.getCode());
if (keysMap == KeysMap.NULL) {
return;
}
String keyText;
if (keysMap == null) {
keyText = e.getText();
} else {
keyText = keysMap.toString();
}
event.put("keyCode", keyText);
} else if (e.getEventType() == KeyEvent.KEY_TYPED && !e.isControlDown() && !needManualRecording(keyCode)) {
char[] cs = e.getCharacter().toCharArray();
if (cs.length == 0) {
return;
}
for (char c : cs) {
if (Character.isISOControl(c) && hasMapping(c)) {
event.put("keyChar", getMapping(c));
} else {
event.put("keyChar", "" + c);
}
}
} else {
return;
}
recordEvent(r, event);
}
示例6: handle
import javafx.scene.input.KeyEvent; //导入方法依赖的package包/类
@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();
}
}
}
示例7: processKeyPressed
import javafx.scene.input.KeyEvent; //导入方法依赖的package包/类
/**
* Handle the key pressed event.
*
* @param event the event
*/
@FXThread
protected void processKeyPressed(@NotNull final KeyEvent event) {
final KeyCode code = event.getCode();
if (code == KeyCode.S && event.isControlDown() && isDirty()) {
save();
} else if (handleKeyActionImpl(code, true, event.isControlDown(), event.isShiftDown(), false)) {
event.consume();
}
}
示例8: handle
import javafx.scene.input.KeyEvent; //导入方法依赖的package包/类
@Override public void handle(KeyEvent event) {
if (event.getEventType() != KeyEvent.KEY_PRESSED) {
return;
}
KeyCode code = event.getCode();
switch (code) {
case ENTER:
positionToLastLine();
boolean collect = false;
if (area.getText().toString().endsWith(";")) {
collect = true;
area.setText(area.getText().substring(0, area.getText().length() - 1));
}
if (collect || event.isShiftDown()) {
collectAction();
} else {
if (functionText.length() > 0) {
collectAction();
}
enterAction(event);
area.setEditable(false);
}
break;
case UP:
positionToLastLine();
upAction(event);
break;
case DOWN:
positionToLastLine();
downAction(event);
break;
case LEFT:
case D:
if (event.isControlDown()) {
event.consume();
inputJoin.send(Channel.LINE, EMPTY_LINE);
}
break;
default:
break;
}
}
示例9: isModifiers
import javafx.scene.input.KeyEvent; //导入方法依赖的package包/类
public static boolean isModifiers(KeyEvent e) {
if (e.isAltDown() || e.isControlDown() || e.isMetaDown() || e.isShiftDown()) {
return true;
}
return false;
}
示例10: getModifiers
import javafx.scene.input.KeyEvent; //导入方法依赖的package包/类
private boolean getModifiers(KeyEvent e) {
return e.isAltDown() || e.isControlDown() || e.isMetaDown() || e.isShiftDown();
}