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

The following examples show how to use javafx.scene.input.KeyEvent#isShiftDown() . 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: StringTable.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
private void handleKey(final KeyEvent event)
{
    if (event.getCode() == KeyCode.TAB)
    {
        // Edit next/prev column in same row
        final ObservableList<TableColumn<List<ObservableCellValue>, ?>> columns = getTableView().getColumns();
        final int col = columns.indexOf(getTableColumn());
        final int next = event.isShiftDown()
                       ? (col + columns.size() - 1) % columns.size()
                       : (col + 1) % columns.size();
        editCell(getIndex(), columns.get(next));
        event.consume();
    }
    else if (event.getCode() == KeyCode.ENTER)
    {
        // Consume 'enter' and move to next row. Space can be used to toggle (or mouse click)
        event.consume();
        editCell(getIndex() + 1, getTableColumn());
    }
}
 
Example 3
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 4
Source File: StringTable.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
private void handleKey(final KeyEvent event)
{
    if (event.getCode() == KeyCode.TAB)
    {
        // Commit value from combo's text field into combo's value...
        combo.commitValue();
        // .. and use that for the cell
        commitEdit(combo.getValue());

        // Edit next/prev column in same row
        final ObservableList<TableColumn<List<ObservableCellValue>, ?>> columns = getTableView().getColumns();
        final int col = columns.indexOf(getTableColumn());
        final int next = event.isShiftDown()
                       ? (col + columns.size() - 1) % columns.size()
                       : (col + 1) % columns.size();
        editCell(getIndex(), columns.get(next));
        event.consume();
    }
}
 
Example 5
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 6
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 7
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 8
Source File: TraverseFocusOnTypeHandler.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void initialPress(KeyEvent event) {
	// discard keystrokes other than TAB
	if (!isTraverse(event)) {
		return;
	}
	// get traversal policy
	FocusTraversalPolicy focusTraversalPolicy = getHost()
			.getAdapter(FocusTraversalPolicy.class);
	if (focusTraversalPolicy == null) {
		throw new IllegalStateException(
				"Cannot find <FocusTraversalPolicy> for host <"
						+ getHost() + ">.");
	}
	// perform focus traversal
	init(focusTraversalPolicy);
	IContentPart<? extends Node> focused = event.isShiftDown()
			? focusTraversalPolicy.focusPrevious()
			: focusTraversalPolicy.focusNext();
	// reveal the newly focused part
	if (focused != null) {
		focused.getRoot().getViewer().reveal(focused);
	}
	// execute on stack
	commit(focusTraversalPolicy);
}
 
Example 9
Source File: WritePane.java    From oim-fx with MIT License 6 votes vote down vote up
private void processKeyEvent(KeyEvent ev) {
	if (webPage == 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();
	}
	System.out.println(ev.getText());
	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: 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 11
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 12
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 13
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 14
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 15
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 16
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 17
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;
}
 
Example 18
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 19
Source File: KeyMap.java    From FxDock with Apache License 2.0 4 votes vote down vote up
protected static KKey key(KeyEvent ev)
	{
		int flags = 0;
		KeyCode cd;
		String ch;
		
		if(ev.getEventType() == KeyEvent.KEY_PRESSED)
		{
			flags |= KEY_PRESSED;
			cd = ev.getCode();
			ch = null;
		}
		else if(ev.getEventType() == KeyEvent.KEY_RELEASED)
		{
			flags |= KEY_RELEASED;
			cd = ev.getCode();
			ch = null;
		}
		else if(ev.getEventType() == KeyEvent.KEY_TYPED)
		{
			flags |= KEY_TYPED;
			cd = null;
			ch = ev.getCharacter();
		}
		else
		{
			throw new Error("?" + ev.getEventType());
		}
		
		if(ev.isAltDown())
		{
			flags |= ALT;
		}
		
		if(ev.isControlDown())
		{
			flags |= CTRL;
		}

		if(ev.isMetaDown())
		{
			flags |= META;
		}

		if(ev.isShiftDown())
		{
			flags |= SHIFT;
		}
		
		if(ev.isShortcutDown())
		{
			flags |= ACTUAL_SHORTCUT;
		}
		
//		D.f("key event 0x%8x %s", flags, ev.getCode());
		
		return new KKey(flags, cd, ch);
	}
 
Example 20
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());
}