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

The following examples show how to use javafx.scene.input.KeyEvent#isAltDown() . 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: JFXKey.java    From tuxguitar with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static UIKeyCombination getCombination(KeyEvent keyEvent) {
	UIKeyCombination keyCombination = new UIKeyCombination();
	if( keyEvent.isAltDown() ) {
		keyCombination.getKeys().add(UIKey.ALT);
	}
	if( keyEvent.isShiftDown() ) {
		keyCombination.getKeys().add(UIKey.SHIFT);
	}
	if( keyEvent.isControlDown() ) {
		keyCombination.getKeys().add(UIKey.CONTROL);
	}
	if( keyEvent.isMetaDown() ) {
		keyCombination.getKeys().add(UIKey.COMMAND);
	}
	
	UIKey principalKey = JFXKey.getKey(keyEvent);
	if(!keyCombination.contains(principalKey)) {
		keyCombination.getKeys().add(principalKey);
	}
	
	return keyCombination;
}
 
Example 2
Source File: WSRecorder.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 3
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 4
Source File: OSFXUtils.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 5
Source File: ImageManufactureController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public void altHandler(KeyEvent event) {
    super.altHandler(event);
    if (event.isAltDown()) {
        String key = event.getText();
        if (key == null || key.isEmpty()) {
            return;
        }
        switch (key) {
            case "p":
            case "P":
                if (!popButton.isDisabled()) {
                    popAction();
                }
                break;
            default:
                break;
        }
    }
}
 
Example 6
Source File: RTImagePlot.java    From phoebus with Eclipse Public License 1.0 6 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.C)
        toolbar.toggleCrosshair();
    else if (event.getCode() == KeyCode.T)
        showToolbar(! isToolbarVisible());
    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 7
Source File: MyBoxLanguagesController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
public void altHandler(KeyEvent event) {
    super.altHandler(event);
    if (!event.isAltDown()) {
        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 altHandler(KeyEvent event) {
    if (!event.isAltDown()) {
        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.altHandler(event);
}
 
Example 9
Source File: ShowPanel.java    From oim-fx with MIT License 6 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 {
		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 10
Source File: ImageManufactureColorController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
@Override
public void eventsHandler(KeyEvent event) {
    keyEventsHandlerDo(event);
    if (!event.isAltDown()) {
        return;
    }
    String key = event.getText();
    if (key == null || key.isEmpty()) {
        return;
    }
    switch (key) {
        case "1":
            if (opBox.getChildren().contains(setButton) && !setButton.isDisabled()) {
                setAction();
            }
            break;
        case "2":
            if (opBox.getChildren().contains(colorIncreaseButton) && !colorIncreaseButton.isDisabled()) {
                increaseAction();
            }
            break;
        case "3":
            if (opBox.getChildren().contains(colorDecreaseButton) && !colorDecreaseButton.isDisabled()) {
                decreaseAction();
            }
            break;
        case "4":
            if (opBox.getChildren().contains(colorFilterButton) && !colorFilterButton.isDisabled()) {
                filterAction();
            }
            break;
        case "5":
            if (opBox.getChildren().contains(colorInvertButton) && !colorInvertButton.isDisabled()) {
                invertAction();
            }
            break;
    }

}
 
Example 11
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 12
Source File: ChatWritePane.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 13
Source File: ConsoleKeyEvent.java    From xframium-java with GNU General Public License v3.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 14
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 15
Source File: EventHandlerTool.java    From VocabHunter with Apache License 2.0 4 votes vote down vote up
public static boolean isWithoutModifier(final KeyEvent event) {
    return !(event.isAltDown() || event.isControlDown() || event.isMetaDown() || event.isShortcutDown() || event.isShiftDown());
}
 
Example 16
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 17
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();
}
 
Example 18
Source File: DragSupport.java    From scenic-view with GNU General Public License v3.0 4 votes vote down vote up
private boolean isModifierCorrect(KeyEvent t, KeyCode keyCode) {
    return (keyCode != KeyCode.ALT ^ t.isAltDown())
            && (keyCode != KeyCode.CONTROL ^ t.isControlDown())
            && (keyCode != KeyCode.SHIFT ^ t.isShiftDown())
            && (keyCode != KeyCode.META ^ t.isMetaDown());
}
 
Example 19
Source File: WSRecorder.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@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);
}
 
Example 20
Source File: JavaFxRecorderHook.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;
}