本文整理匯總了Java中javafx.scene.input.KeyCodeCombination.getAlt方法的典型用法代碼示例。如果您正苦於以下問題:Java KeyCodeCombination.getAlt方法的具體用法?Java KeyCodeCombination.getAlt怎麽用?Java KeyCodeCombination.getAlt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.input.KeyCodeCombination
的用法示例。
在下文中一共展示了KeyCodeCombination.getAlt方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: keysDown
import javafx.scene.input.KeyCodeCombination; //導入方法依賴的package包/類
/**
* Presses the provided {@link KeyCodeCombination}'s keys.
*
* @param kb the KeyCodeCombination
* @return true, if successful
*/
@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;
}
示例2: keysUp
import javafx.scene.input.KeyCodeCombination; //導入方法依賴的package包/類
/**
* Releases the provided {@link KeyCodeCombination}'s keys.
*
* @param kb the KeyCodeCombination
* @return true, if successful
*/
@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;
}
示例3: getKeyCodes
import javafx.scene.input.KeyCodeCombination; //導入方法依賴的package包/類
private List<KeyCode> getKeyCodes(KeyCodeCombination combination) {
List<KeyCode> keys = new ArrayList<>();
if (combination.getAlt() == KeyCombination.ModifierValue.DOWN) {
keys.add(KeyCode.ALT);
}
if (combination.getShift() == KeyCombination.ModifierValue.DOWN) {
keys.add(KeyCode.SHIFT);
}
if (combination.getMeta() == KeyCombination.ModifierValue.DOWN) {
keys.add(KeyCode.META);
}
if (combination.getControl() == KeyCombination.ModifierValue.DOWN) {
keys.add(KeyCode.CONTROL);
}
if (combination.getShortcut() == KeyCombination.ModifierValue.DOWN) {
// Fix bug with internal method not having a proper code for SHORTCUT.
// Dispatch manually based on platform.
if (PlatformSpecific.isOnMac()) {
keys.add(KeyCode.META);
} else {
keys.add(KeyCode.CONTROL);
}
}
keys.add(combination.getCode());
return keys;
}
示例4: type
import javafx.scene.input.KeyCodeCombination; //導入方法依賴的package包/類
@Override
public RController type(KeyCodeCombination... combinations) {
for( KeyCodeCombination combination : combinations ) {
if( combination.getAlt() == ModifierValue.DOWN ) {
glassRobot.keyPress(JavaFXCompatUtil.getCode(KeyCode.ALT));
}
if( combination.getShift() == ModifierValue.DOWN ) {
glassRobot.keyPress(JavaFXCompatUtil.getCode(KeyCode.SHIFT));
}
if( combination.getControl() == ModifierValue.DOWN ) {
glassRobot.keyPress(JavaFXCompatUtil.getCode(KeyCode.CONTROL));
}
glassRobot.keyPress(JavaFXCompatUtil.getCode(combination.getCode()));
glassRobot.keyRelease(JavaFXCompatUtil.getCode(combination.getCode()));
if( combination.getAlt() == ModifierValue.DOWN ) {
glassRobot.keyRelease(JavaFXCompatUtil.getCode(KeyCode.ALT));
}
if( combination.getShift() == ModifierValue.DOWN ) {
glassRobot.keyRelease(JavaFXCompatUtil.getCode(KeyCode.SHIFT));
}
if( combination.getControl() == ModifierValue.DOWN ) {
glassRobot.keyRelease(JavaFXCompatUtil.getCode(KeyCode.CONTROL));
}
}
return this;
}
示例5: modifiersTextFromKeyCombination
import javafx.scene.input.KeyCodeCombination; //導入方法依賴的package包/類
private String modifiersTextFromKeyCombination(KeyCodeCombination kcc) {
if (kcc == null) {
return "";
}
ModifierValue downMod = ModifierValue.DOWN;
// If any modifier exist
if (kcc.getAlt() == downMod || kcc.getShortcut() == downMod || kcc.getShift() == downMod) {
String FullHotkey = kcc.getDisplayText();
int lastPlusSignIndex = FullHotkey.lastIndexOf("+");
return FullHotkey.substring(0, lastPlusSignIndex);
}
return "";
}
示例6: modifiersTextFromKeyCombination
import javafx.scene.input.KeyCodeCombination; //導入方法依賴的package包/類
private String modifiersTextFromKeyCombination(KeyCodeCombination kcc) {
if (kcc == null) {
return "";
}
ModifierValue downMod = ModifierValue.DOWN;
// If any modifier exist
if (kcc.getAlt() == downMod || kcc.getShortcut() == downMod || kcc.getShift() == downMod) {
String FullHotkeyText = kcc.getDisplayText();
int lastPlusSignIndex = FullHotkeyText.lastIndexOf("+");
return FullHotkeyText.substring(0, lastPlusSignIndex);
}
return "";
}
示例7: nativeKeyPressed
import javafx.scene.input.KeyCodeCombination; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@Override
public void nativeKeyPressed(NativeKeyEvent e) {
if (hotkeyIsPressed) {
return; // Do nothing if Hotkey is already pressed.
}
int modifiers = e.getModifiers();
if (modifiers == 0)
return; // Do nothing when no modifiers are pressed, because it's not a hotkey.
boolean isAltPressed = (modifiers & NativeKeyEvent.ALT_MASK) != 0;
boolean isShiftPressed = (modifiers & NativeKeyEvent.SHIFT_MASK) != 0;
// Shortcut modifier is Control modifier in Windows/Linux system and Meta (Command) in
// Mac systems.
boolean isShortcutPressed = (modifiers & NativeKeyEvent.CTRL_MASK)
+ (modifiers & NativeKeyEvent.META_MASK) != 0;
for (Entry<Hotkey, ObjectProperty<KeyCodeCombination>> entry : registeredHotkeys
.entrySet()) {
KeyCodeCombination kcc = entry.getValue().get();
if (kcc == null)
continue; // Do nothing if KeyCodeCombination is not set for this Hotkey.
// FIXME: provide compatibility with Java 9 (pretty easy).
if (e.getRawCode() != kcc.getCode().impl_getCode())
continue; // Key code does not match Hotkey.
if (isAltPressed != (kcc.getAlt() == ModifierValue.DOWN))
continue; // Alt modifier doesn't match Hotkey.
if (isShiftPressed != (kcc.getShift() == ModifierValue.DOWN))
continue; // Shift modifier doesn't match Hotkey.
if (isShortcutPressed != (kcc.getShortcut() == ModifierValue.DOWN))
continue; // Shortcut modifier doesn't match Hotkey.
if (hotkeyIsRunning) {
logger.error("Previously pressed Hotkey is still running.");
return; // Do nothing if Hotkey is still running.
}
// At this point the pressed key and modifiers match one of the registered Hotkeys.
// Let's run the associated runnable with this Hotkey.
Hotkey hotkey = entry.getKey();
logger.info("Catched the Hotkey: \"" + hotkey.name()
+ "\". Running the associated action.");
hotkeyIsPressed = true;
hotkeyIsRunning = true;
Runnable task = () -> {
hotkey.run();
logger.info("Finished running the action associated with the Hotkey: \""
+ hotkey.name() + "\".");
hotkeyIsRunning = false;
};
new Thread(task).start();
break;
}
}