Java Code Examples for javafx.scene.input.KeyEvent#isControlDown()

The following examples show how to use javafx.scene.input.KeyEvent#isControlDown() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EventQueueDeviceTest.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: ImageManufactureBatchEffectsController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public void keyEventsHandler(KeyEvent event) {
    super.keyEventsHandler(event);
    if (event.isControlDown()) {
        String key = event.getText();
        if (key == null || key.isEmpty()) {
            return;
        }
        switch (key) {
            case "k":
            case "K":
                if (stringBox != null) {
                    stringBox.show();
                }
                break;
        }
    }
}
 
Example 3
Source File: ImageViewerController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public void keyEventsHandler(KeyEvent event) {
    super.keyEventsHandler(event);
    if (event.isControlDown()) {
        String key = event.getText();
        if (key == null || key.isEmpty()) {
            return;
        }
        switch (key) {
            case "t":
            case "T":
                if (selectAreaCheck != null) {
                    selectAreaCheck.setSelected(!selectAreaCheck.isSelected());
                }
                break;
            default:
                break;
        }
    }
}
 
Example 4
Source File: ImageManufactureController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public void controlHandler(KeyEvent event) {
    super.controlHandler(event);
    if (event.isControlDown()) {
        String key = event.getText();
        if (key == null || key.isEmpty()) {
            return;
        }
        switch (key) {
            case "p":
            case "P":
                if (!popButton.isDisabled()) {
                    popAction();
                }
                break;
            default:
                break;
        }
    }
}
 
Example 5
Source File: JavaFxRecorderHook.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 6
Source File: WebViewEventDispatcher.java    From oim-fx with MIT License 6 votes vote down vote up
private void processKeyEvent(KeyEvent ev) {
    if (page == null) return;

    String text = null;
    String keyIdentifier = null;
    int windowsVirtualKeyCode = 0;
    if(ev.getEventType() == KeyEvent.KEY_TYPED) {
        text = ev.getCharacter();
    } else {
        KeyCodeMap.Entry keyCodeEntry = KeyCodeMap.lookup(ev.getCode());
        keyIdentifier = keyCodeEntry.getKeyIdentifier();
        windowsVirtualKeyCode = keyCodeEntry.getWindowsVirtualKeyCode();
    }

    WCKeyEvent keyEvent = new WCKeyEvent(
            idMap.get(ev.getEventType()),
            text,
            keyIdentifier,
            windowsVirtualKeyCode,
            ev.isShiftDown(), ev.isControlDown(),
            ev.isAltDown(), ev.isMetaDown(), System.currentTimeMillis());
    if (page.dispatchKeyEvent(keyEvent)) {
        ev.consume();
    }
}
 
Example 7
Source File: MyBoxLanguagesController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public void controlHandler(KeyEvent event) {
    super.controlHandler(event);
    if (!event.isControlDown()) {
        return;
    }
    String key = event.getText();
    if (key == null || key.isEmpty()) {
        return;
    }
    switch (key) {
        case "e":
        case "E":
            copyEnglish();
            return;

    }
}
 
Example 8
Source File: DataAnalysisController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public void controlHandler(KeyEvent event) {
    if (!event.isControlDown()) {
        return;
    }
    String key = event.getText();
    if (key != null) {
        switch (key) {
            case "q":
            case "Q":
                queryData();
                return;
            case "e":
            case "E":
                exportData();
                return;
            case "r":
            case "R":
                clearAction();
        }
    }
    super.controlHandler(event);
}
 
Example 9
Source File: MainController.java    From dev-tools with Apache License 2.0 5 votes vote down vote up
@FXML
private void handleKeyInput(final InputEvent event) {
    if (event instanceof KeyEvent) {
        final KeyEvent keyEvent = (KeyEvent) event;
        if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.A) {
            debug("handleKeyInput");
        }
    }
}
 
Example 10
Source File: ConfKeybinding.java    From Recaf with MIT License 5 votes vote down vote up
private static Set<String> namesOf(KeyEvent event) {
	Set<String> eventSet = new HashSet<>();
	eventSet.add(event.getCode().getName().toLowerCase());
	if (event.isControlDown())
		eventSet.add("ctrl");
	else if (event.isAltDown())
		eventSet.add("alt");
	else if (event.isShiftDown())
		eventSet.add("shift");
	return eventSet;
}
 
Example 11
Source File: ImageBaseController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
@Override
public void keyEventsHandler(KeyEvent event) {
    super.keyEventsHandler(event);
    if (event.isControlDown()) {
        String key = event.getText();
        if (key == null || key.isEmpty()) {
            return;
        }
        switch (key) {
            case "1":
                if (imageSizeButton != null && !imageSizeButton.isDisabled()) {
                    loadedSize();
                }
                break;
            case "2":
                if (paneSizeButton != null && !paneSizeButton.isDisabled()) {
                    paneSize();
                }
                break;
            case "3":
                if (zoomInButton != null && !zoomInButton.isDisabled()) {
                    zoomIn();
                }
                break;
            case "4":
                if (zoomOutButton != null && !zoomOutButton.isDisabled()) {
                    zoomOut();
                }
                break;
        }

    }
}
 
Example 12
Source File: RTPlot.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** onKeyPressed */
private void keyPressed(final KeyEvent event)
{
    if (! handle_keys || axisLimitsField.isVisible() )
        return;
    if (event.getCode() == KeyCode.Z)
        plot.getUndoableActionManager().undoLast();
    else if (event.getCode() == KeyCode.Y)
        plot.getUndoableActionManager().redoLast();
    else if (event.getCode() == KeyCode.O)
        showConfigurationDialog();
    else if (event.getCode() == KeyCode.T)
        showToolbar(! isToolbarVisible());
    else if (event.getCode() == KeyCode.C)
        toolbar.toggleCrosshair();
    else if (event.getCode() == KeyCode.L)
        plot.showLegend(! plot.isLegendVisible());
    else if (event.getCode() == KeyCode.S)
        plot.stagger(true);
    else if (event.getCode() == KeyCode.A)
        plot.enableAutoScale();
    else if (event.isControlDown())
        toolbar.selectMouseMode(MouseMode.ZOOM_IN);
    else if (event.isAltDown())
        toolbar.selectMouseMode(MouseMode.ZOOM_OUT);
    else if (event.isShiftDown())
        toolbar.selectMouseMode(MouseMode.PAN);
    else
        toolbar.selectMouseMode(MouseMode.NONE);
    event.consume();
}
 
Example 13
Source File: WritePanel.java    From oim-fx with MIT License 5 votes vote down vote up
public void processKeyEvent(KeyEvent ev) {
	if (webPage == null)
		return;
	ev.consume();
	String text = null;
	String keyIdentifier = null;
	int windowsVirtualKeyCode = 0;
	if (ev.getEventType() == KeyEvent.KEY_TYPED) {
		text = ev.getCharacter();
	} else {
		System.out.println(ev.getCode());
		KeyCodeMap.Entry keyCodeEntry = KeyCodeMap.lookup(ev.getCode());
		keyIdentifier = keyCodeEntry.getKeyIdentifier();
		windowsVirtualKeyCode = keyCodeEntry.getWindowsVirtualKeyCode();
	}

	WCKeyEvent keyEvent = new WCKeyEvent(
			idMap.get(ev.getEventType()),
			text,
			keyIdentifier,
			windowsVirtualKeyCode,
			ev.isShiftDown(), ev.isControlDown(),
			ev.isAltDown(), ev.isMetaDown(), System.currentTimeMillis());
	if (webPage.dispatchKeyEvent(keyEvent)) {
		ev.consume();
	}
}
 
Example 14
Source File: ConsoleKeyEvent.java    From dm3270 with Apache License 2.0 5 votes vote down vote up
@Override
public void handle (KeyEvent e)                     // onKeyTyped
{
  if (e.getEventType () != KeyEvent.KEY_TYPED)
    return;
  String c = e.getCharacter ();
  if (c.isEmpty ())
    return;
  char ch = c.charAt (0);

  if (screen.isKeyboardLocked () || e.isMetaDown () || e.isControlDown ()
      || e.isAltDown ())
  {
    // seems to be a bug in java
    if (e.isMetaDown ())
    {
      if (ch == '-')                    // osx fix
      {
        screen.getFontManager ().smaller ();
        e.consume ();
      }
      else if (ch == '=')               // osx fix
      {
        screen.getFontManager ().bigger ();
        e.consume ();
      }
    }

    return;
  }

  if (ch >= 32 && ch < 0x7F)
  {
    cursor.typeChar ((byte) Dm3270Utility.asc2ebc[ch]);
    e.consume ();
  }
}
 
Example 15
Source File: JsonTabController.java    From dev-tools with Apache License 2.0 5 votes vote down vote up
@FXML
private void handleSearchBarEvent(final KeyEvent event) {
    if (event.isControlDown() && event.getCode() == KeyCode.F) {
        barSearch.setVisible(true);
        barSearch.setManaged(true);
        fieldSearch.requestFocus();
    } else if (event.getCode() == KeyCode.ESCAPE) {
        barSearch.setVisible(false);
        barSearch.setManaged(false);
    }
}
 
Example 16
Source File: Preferences_Controller.java    From Path-of-Leveling with MIT License 4 votes vote down vote up
private KeyCombination handleKeybindEdit(KeyEvent event, TextField kc_field, int nodeID){
    if(event.isAltDown()){
        key_bind = "Alt+";
        if(event.getCode().getName().equals("Alt")){
            key_bind = "Alt";
        }else{
            key_bind += event.getCode().getName();
        }
    }else if(event.isControlDown()){
        key_bind = "Ctrl+";
        if(event.getCode().getName().equals("Ctrl")){
            key_bind = "Ctrl";
        }else{
            key_bind += event.getCode().getName();
        }

    }else if(event.isShiftDown()){
        key_bind = "Shift+";
        if(event.getCode().getName().equals("Shift")){
            key_bind = "Shift";
        }else{
            key_bind += event.getCode().getName();
        }

    }else{
        key_bind += event.getCode().getName();
    }
    KeyCombination kc_temp;
    try{
        kc_temp = KeyCombination.keyCombination(key_bind);
        isBeingUsed(kc_temp,nodeID);
        kc_field.setText(key_bind);
        //System.out.println("key code : " + kc_temp.getName());
        //zones_hotkey_show_hide_key = keyCombination;
    }catch(IllegalArgumentException e){
        kc_field.setText("");
        //System.out.println(":incorect:");
        kc_temp = KeyCombination.NO_MATCH;
    }finally{
        key_bind = "";
    }
    return kc_temp;
}
 
Example 17
Source File: KeyButtonEventHandler.java    From jfxvnc with Apache License 2.0 4 votes vote down vote up
private static boolean isModifierPressed(KeyEvent event) {
  return event.isAltDown() || event.isControlDown() || event.isMetaDown() || event.isShortcutDown();
}
 
Example 18
Source File: TextAreaReadline.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@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;
    }
}
 
Example 19
Source File: OSFXUtils.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public static boolean isModifiers(KeyEvent e) {
    if (e.isAltDown() || e.isControlDown() || e.isMetaDown() || e.isShiftDown()) {
        return true;
    }
    return false;
}
 
Example 20
Source File: KeyHelper.java    From AsciidocFX with Apache License 2.0 4 votes vote down vote up
public static boolean isAnyDown(KeyEvent event) {
    return event.isShortcutDown() || event.isShiftDown() || event.isControlDown() || event.isAltDown();
}