Example usage for javafx.scene.input KeyCodeCombination getAlt

List of usage examples for javafx.scene.input KeyCodeCombination getAlt

Introduction

In this page you can find the example usage for javafx.scene.input KeyCodeCombination getAlt.

Prototype

public final ModifierValue getAlt() 

Source Link

Document

The state of the alt key in this key combination.

Usage

From source file:com.ubershy.streamsis.actions.HotkeyAction.java

/**
 * Presses the provided {@link KeyCodeCombination}'s keys.
 *
 * @param kb            the KeyCodeCombination
 * @return true, if successful//ww w.ja v a 2s.  co  m
 */
@SuppressWarnings("deprecation")
protected boolean keysDown(KeyCodeCombination kb) {
    try {
        if (kb.getShortcut() == ModifierValue.DOWN) {
            robot.keyPress(shortcutKeyEvent);
            Thread.sleep(modifiersPressSleepTime);
        }
        if (kb.getAlt() == ModifierValue.DOWN) {
            robot.keyPress(KeyEvent.VK_ALT);
            Thread.sleep(modifiersPressSleepTime);
        }
        if (kb.getShift() == ModifierValue.DOWN) {
            robot.keyPress(KeyEvent.VK_SHIFT);
            Thread.sleep(modifiersPressSleepTime);
        }
        // I know this is a bad practice. Do you have any idea how to avoid this, stranger?
        robot.keyPress(kb.getCode().impl_getCode());
        Thread.sleep(modifiersPressSleepTime);
    } catch (InterruptedException e) {
        logger.debug("Haha, not this time, InterruptedException!");
        return false;
    }
    return true;
}

From source file:com.ubershy.streamsis.actions.HotkeyAction.java

/**
 * Releases the provided {@link KeyCodeCombination}'s keys.
 *
 * @param kb            the KeyCodeCombination
 * @return true, if successful/*from  w ww  . ja va2s .  com*/
 */
@SuppressWarnings("deprecation")
protected boolean keysUp(KeyCodeCombination kb) {
    try {
        // I know this is a bad practice. Do you have any idea how to avoid this, stranger?
        robot.keyRelease(kb.getCode().impl_getCode());
        Thread.sleep(modifiersPressSleepTime);
        if (kb.getShift() == ModifierValue.DOWN) {
            robot.keyRelease(KeyEvent.VK_SHIFT);
            Thread.sleep(modifiersPressSleepTime);
        }
        if (kb.getAlt() == ModifierValue.DOWN) {
            robot.keyRelease(KeyEvent.VK_ALT);
            Thread.sleep(modifiersPressSleepTime);
        }
        if (kb.getShortcut() == ModifierValue.DOWN) {
            robot.keyRelease(shortcutKeyEvent);
        }
    } catch (InterruptedException e) {
        logger.debug("Haha, not this time, InterruptedException!");
        return false;
    }
    return true;
}