Java Code Examples for javafx.scene.input.KeyCode#SPACE

The following examples show how to use javafx.scene.input.KeyCode#SPACE . 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: AutocompleteMenu.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
/** Toggle menu on Ctrl-Space
 *
 *  <p>Called by both the text field and the context menu
 */
private void toggleMenu(final KeyEvent event)
{
    // For Mac, isShortcutDown() to detect Command-SPACE
    // seemed natural, but that is already captured by OS
    // for 'Spotlight Search',
    // so use Ctrl-Space on all OS
    if (event.isControlDown()  &&  event.getCode() == KeyCode.SPACE)
    {
        if (menu.isShowing())
            menu.hide();
        else if (event.getSource() instanceof TextField)
        {
            final TextInputControl field = (TextInputControl) event.getSource();
            // Show menu with current content,
            // in case we were hiding and are now showing the menu
            // for the same field, not loosing focus,
            // menu already populated
            showMenuForField(field);
            // Certainly need to perform lookup if menu is empty.
            // Otherwise, cannot hurt to 'refresh'
            lookup(field);
        }
        event.consume();
    }
}
 
Example 2
Source File: Button.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public boolean keyPressed(CircuitManager manager, CircuitState state, KeyCode keyCode, String text) {
	if(keyCode == KeyCode.SPACE) {
		mousePressed(manager, state, 0, 0);
	}
	
	return false;
}
 
Example 3
Source File: OSFXUtils.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public static String keyEventGetKeyText(KeyCode keycode) {
    if (keycode == KeyCode.TAB) {
        return "Tab";
    }
    if (keycode == KeyCode.CONTROL) {
        return "Ctrl";
    }
    if (keycode == KeyCode.ALT) {
        return "Alt";
    }
    if (keycode == KeyCode.SHIFT) {
        return "Shift";
    }
    if (keycode == KeyCode.META) {
        return "Meta";
    }
    if (keycode == KeyCode.SPACE) {
        return "Space";
    }
    if (keycode == KeyCode.BACK_SPACE) {
        return "Backspace";
    }
    if (keycode == KeyCode.HOME) {
        return "Home";
    }
    if (keycode == KeyCode.END) {
        return "End";
    }
    if (keycode == KeyCode.DELETE) {
        return "Delete";
    }
    if (keycode == KeyCode.PAGE_UP) {
        return "Pageup";
    }
    if (keycode == KeyCode.PAGE_DOWN) {
        return "Pagedown";
    }
    if (keycode == KeyCode.UP) {
        return "Up";
    }
    if (keycode == KeyCode.DOWN) {
        return "Down";
    }
    if (keycode == KeyCode.LEFT) {
        return "Left";
    }
    if (keycode == KeyCode.RIGHT) {
        return "Right";
    }
    if (keycode == KeyCode.ENTER) {
        return "Enter";
    }
    return keycode.getName();
}
 
Example 4
Source File: WSRecorder.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
private boolean needManualRecording(KeyCode keyCode) {
    return keyCode == KeyCode.BACK_SPACE || keyCode == KeyCode.DELETE || keyCode == KeyCode.ESCAPE || keyCode == KeyCode.SPACE;
}
 
Example 5
Source File: JavaFxRecorderHook.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public static String keyEventGetKeyText(KeyCode keyCode) {
    if (keyCode == KeyCode.TAB) {
        return "Tab";
    }
    if (keyCode == KeyCode.CONTROL) {
        return "Ctrl";
    }
    if (keyCode == KeyCode.ALT) {
        return "Alt";
    }
    if (keyCode == KeyCode.SHIFT) {
        return "Shift";
    }
    if (keyCode == KeyCode.META) {
        return "Meta";
    }
    if (keyCode == KeyCode.SPACE) {
        return "Space";
    }
    if (keyCode == KeyCode.BACK_SPACE) {
        return "Backspace";
    }
    if (keyCode == KeyCode.HOME) {
        return "Home";
    }
    if (keyCode == KeyCode.END) {
        return "End";
    }
    if (keyCode == KeyCode.DELETE) {
        return "Delete";
    }
    if (keyCode == KeyCode.PAGE_UP) {
        return "Pageup";
    }
    if (keyCode == KeyCode.PAGE_DOWN) {
        return "Pagedown";
    }
    if (keyCode == KeyCode.UP) {
        return "Up";
    }
    if (keyCode == KeyCode.DOWN) {
        return "Down";
    }
    if (keyCode == KeyCode.LEFT) {
        return "Left";
    }
    if (keyCode == KeyCode.RIGHT) {
        return "Right";
    }
    if (keyCode == KeyCode.ENTER) {
        return "Enter";
    }
    return keyCode.getName();
}
 
Example 6
Source File: RFXCheckBox.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
protected void keyPressed(KeyEvent ke) {
    if (ke.getCode() == KeyCode.SPACE) {
        recorder.recordRawKeyEvent(this, ke);
    }
}
 
Example 7
Source File: RFXToggleButton.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
protected void keyPressed(KeyEvent ke) {
    if (ke.getCode() == KeyCode.SPACE) {
        recorder.recordRawKeyEvent(this, ke);
    }
}
 
Example 8
Source File: RFXButtonBase.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
protected void keyPressed(KeyEvent ke) {
    if (ke.getCode() == KeyCode.SPACE) {
        recorder.recordRawKeyEvent(this, ke);
    }
}
 
Example 9
Source File: Button.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void keyReleased(CircuitManager manager, CircuitState state, KeyCode keyCode, String text) {
	if(keyCode == KeyCode.SPACE) {
		mouseReleased(manager, state, 0, 0);
	}
}