本文整理汇总了Java中java.awt.event.InputEvent.CTRL_DOWN_MASK属性的典型用法代码示例。如果您正苦于以下问题:Java InputEvent.CTRL_DOWN_MASK属性的具体用法?Java InputEvent.CTRL_DOWN_MASK怎么用?Java InputEvent.CTRL_DOWN_MASK使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.awt.event.InputEvent
的用法示例。
在下文中一共展示了InputEvent.CTRL_DOWN_MASK属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getModifiers
/**
* Converts XEMBED modifiers mask into AWT InputEvent mask
*/
int getModifiers(int state) {
int mods = 0;
if ((state & XEMBED_MODIFIER_SHIFT) != 0) {
mods |= InputEvent.SHIFT_DOWN_MASK;
}
if ((state & XEMBED_MODIFIER_CONTROL) != 0) {
mods |= InputEvent.CTRL_DOWN_MASK;
}
if ((state & XEMBED_MODIFIER_ALT) != 0) {
mods |= InputEvent.ALT_DOWN_MASK;
}
// FIXME: What is super/hyper?
// FIXME: Experiments show that SUPER is ALT. So what is Alt then?
if ((state & XEMBED_MODIFIER_SUPER) != 0) {
mods |= InputEvent.ALT_DOWN_MASK;
}
// if ((state & XEMBED_MODIFIER_HYPER) != 0) {
// mods |= InputEvent.DOWN_MASK;
// }
return mods;
}
示例2: keyStrokeToString
public static String keyStrokeToString(KeyStroke keyStroke) {
int modifiers = keyStroke.getModifiers();
StringBuffer sb = new StringBuffer();
if ((modifiers & InputEvent.CTRL_DOWN_MASK) > 0) {
sb.append("Ctrl+"); // NOI18N
}
if ((modifiers & InputEvent.ALT_DOWN_MASK) > 0) {
sb.append("Alt+"); // NOI18N
}
if ((modifiers & InputEvent.SHIFT_DOWN_MASK) > 0) {
sb.append("Shift+"); // NOI18N
}
if ((modifiers & InputEvent.META_DOWN_MASK) > 0) {
sb.append("Meta+"); // NOI18N
}
if (keyStroke.getKeyCode() != KeyEvent.VK_SHIFT &&
keyStroke.getKeyCode() != KeyEvent.VK_CONTROL &&
keyStroke.getKeyCode() != KeyEvent.VK_META &&
keyStroke.getKeyCode() != KeyEvent.VK_ALT &&
keyStroke.getKeyCode() != KeyEvent.VK_ALT_GRAPH) {
sb.append(Utilities.keyToString(
KeyStroke.getKeyStroke(keyStroke.getKeyCode(), 0)));
}
return sb.toString();
}
示例3: getKeyModifierText
public static String getKeyModifierText(int modifiers) {
if (modifiers == 0) {
return "";
}
StringBuffer sb = new StringBuffer();
if ((modifiers & InputEvent.CTRL_DOWN_MASK) != 0) {
sb.append("Ctrl+");
}
if ((modifiers & InputEvent.ALT_DOWN_MASK) != 0) {
sb.append("Alt+");
}
if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0) {
sb.append("Shift+");
}
if ((modifiers & InputEvent.META_DOWN_MASK) != 0) {
sb.append("Meta+");
}
return sb.toString();
}
示例4: setOldModifiers
/**
* Sets old modifiers by the new ones.
*/
private void setOldModifiers() {
if ((gestureModifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) {
gestureModifiers |= InputEvent.BUTTON1_MASK;
}
if ((gestureModifiers & InputEvent.BUTTON2_DOWN_MASK) != 0) {
gestureModifiers |= InputEvent.BUTTON2_MASK;
}
if ((gestureModifiers & InputEvent.BUTTON3_DOWN_MASK) != 0) {
gestureModifiers |= InputEvent.BUTTON3_MASK;
}
if ((gestureModifiers & InputEvent.SHIFT_DOWN_MASK) != 0) {
gestureModifiers |= InputEvent.SHIFT_MASK;
}
if ((gestureModifiers & InputEvent.CTRL_DOWN_MASK) != 0) {
gestureModifiers |= InputEvent.CTRL_MASK;
}
if ((gestureModifiers & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) {
gestureModifiers |= InputEvent.ALT_GRAPH_MASK;
}
}
示例5: toKeyDisplayString
public static String toKeyDisplayString(int mods) {
ArrayList<String> arr = new ArrayList<String>();
if ((mods & InputEvent.META_DOWN_MASK) != 0)
arr.add(Strings.get("metaMod"));
if ((mods & InputEvent.CTRL_DOWN_MASK) != 0)
arr.add(Strings.get("ctrlMod"));
if ((mods & InputEvent.ALT_DOWN_MASK) != 0)
arr.add(Strings.get("altMod"));
if ((mods & InputEvent.SHIFT_DOWN_MASK) != 0)
arr.add(Strings.get("shiftMod"));
Iterator<String> it = arr.iterator();
if (it.hasNext()) {
StringBuilder ret = new StringBuilder();
ret.append(it.next());
while (it.hasNext()) {
ret.append(" ");
ret.append(it.next());
}
return ret.toString();
} else {
return "";
}
}
示例6: setNewModifiers
/**
* Sets new modifiers by the old ones.
* The mouse modifiers have higher priority than overlaying key
* modifiers.
*/
@SuppressWarnings("deprecation")
private void setNewModifiers() {
if ((gestureModifiers & InputEvent.BUTTON1_MASK) != 0) {
gestureModifiers |= InputEvent.BUTTON1_DOWN_MASK;
}
if ((gestureModifiers & InputEvent.BUTTON2_MASK) != 0) {
gestureModifiers |= InputEvent.BUTTON2_DOWN_MASK;
}
if ((gestureModifiers & InputEvent.BUTTON3_MASK) != 0) {
gestureModifiers |= InputEvent.BUTTON3_DOWN_MASK;
}
if ((gestureModifiers & InputEvent.SHIFT_MASK) != 0) {
gestureModifiers |= InputEvent.SHIFT_DOWN_MASK;
}
if ((gestureModifiers & InputEvent.CTRL_MASK) != 0) {
gestureModifiers |= InputEvent.CTRL_DOWN_MASK;
}
if ((gestureModifiers & InputEvent.ALT_GRAPH_MASK) != 0) {
gestureModifiers |= InputEvent.ALT_GRAPH_DOWN_MASK;
}
}
示例7: mapOldModifiers
@SuppressWarnings("deprecation")
private static int mapOldModifiers(int modifiers) {
if ((modifiers & InputEvent.SHIFT_MASK) != 0) {
modifiers |= InputEvent.SHIFT_DOWN_MASK;
}
if ((modifiers & InputEvent.ALT_MASK) != 0) {
modifiers |= InputEvent.ALT_DOWN_MASK;
}
if ((modifiers & InputEvent.ALT_GRAPH_MASK) != 0) {
modifiers |= InputEvent.ALT_GRAPH_DOWN_MASK;
}
if ((modifiers & InputEvent.CTRL_MASK) != 0) {
modifiers |= InputEvent.CTRL_DOWN_MASK;
}
if ((modifiers & InputEvent.META_MASK) != 0) {
modifiers |= InputEvent.META_DOWN_MASK;
}
modifiers &= InputEvent.SHIFT_DOWN_MASK
| InputEvent.ALT_DOWN_MASK
| InputEvent.ALT_GRAPH_DOWN_MASK
| InputEvent.CTRL_DOWN_MASK
| InputEvent.META_DOWN_MASK
| InputEvent.BUTTON1_DOWN_MASK
| InputEvent.BUTTON2_DOWN_MASK
| InputEvent.BUTTON3_DOWN_MASK;
return modifiers;
}
示例8: mouseMoved
public void mouseMoved (MouseEvent e) {
JEditorPane c = (JEditorPane) e.getComponent ();
final NbEditorDocument doc = (NbEditorDocument) c.getDocument ();
if (highlight != null) highlight.remove ();
highlight = null;
runnable = null;
if (((e.getModifiers() | e.getModifiersEx()) & InputEvent.CTRL_DOWN_MASK) != InputEvent.CTRL_DOWN_MASK) {
return;
}
int offset = c.viewToModel (e.getPoint ());
highlight (doc, offset);
c.repaint ();
}
示例9: testLassoConditions
private boolean testLassoConditions(MouseEvent e) {
int onmask = InputEvent.BUTTON1_DOWN_MASK;
int offmask = InputEvent.CTRL_DOWN_MASK
| InputEvent.SHIFT_DOWN_MASK;
return (e.getModifiersEx() & (onmask | offmask)) == onmask
&& (enabled || isLDown);
}
示例10: getKeyStrokeAsText
/**
* Get human-readable name for a {@link KeyStroke}.
*/
public static String getKeyStrokeAsText(@NonNull KeyStroke keyStroke) {
int modifiers = keyStroke.getModifiers ();
StringBuilder sb = new StringBuilder ();
if ((modifiers & InputEvent.CTRL_DOWN_MASK) > 0) {
sb.append(EMACS_CTRL);
}
if ((modifiers & InputEvent.ALT_DOWN_MASK) > 0) {
sb.append(STRING_ALT);
}
if ((modifiers & InputEvent.SHIFT_DOWN_MASK) > 0) {
sb.append (EMACS_SHIFT);
}
if ((modifiers & InputEvent.META_DOWN_MASK) > 0) {
sb.append(STRING_META);
}
if (keyStroke.getKeyCode () != KeyEvent.VK_SHIFT &&
keyStroke.getKeyCode () != KeyEvent.VK_CONTROL &&
keyStroke.getKeyCode () != KeyEvent.VK_META &&
keyStroke.getKeyCode () != KeyEvent.VK_ALT &&
keyStroke.getKeyCode () != KeyEvent.VK_ALT_GRAPH) {
sb.append (Utilities.keyToString (
KeyStroke.getKeyStroke (keyStroke.getKeyCode (), 0)
));
}
return sb.toString ();
}
示例11: mapOldModifiers
private static int mapOldModifiers(int modifiers) {
if ((modifiers & InputEvent.SHIFT_MASK) != 0) {
modifiers |= InputEvent.SHIFT_DOWN_MASK;
}
if ((modifiers & InputEvent.ALT_MASK) != 0) {
modifiers |= InputEvent.ALT_DOWN_MASK;
}
if ((modifiers & InputEvent.ALT_GRAPH_MASK) != 0) {
modifiers |= InputEvent.ALT_GRAPH_DOWN_MASK;
}
if ((modifiers & InputEvent.CTRL_MASK) != 0) {
modifiers |= InputEvent.CTRL_DOWN_MASK;
}
if ((modifiers & InputEvent.META_MASK) != 0) {
modifiers |= InputEvent.META_DOWN_MASK;
}
modifiers &= InputEvent.SHIFT_DOWN_MASK
| InputEvent.ALT_DOWN_MASK
| InputEvent.ALT_GRAPH_DOWN_MASK
| InputEvent.CTRL_DOWN_MASK
| InputEvent.META_DOWN_MASK
| InputEvent.BUTTON1_DOWN_MASK
| InputEvent.BUTTON2_DOWN_MASK
| InputEvent.BUTTON3_DOWN_MASK;
return modifiers;
}
示例12: modifiersBits
private static int modifiersBits(int modifiers) {
return modifiers & (
InputEvent.SHIFT_DOWN_MASK |
InputEvent.CTRL_DOWN_MASK |
InputEvent.ALT_DOWN_MASK |
InputEvent.META_DOWN_MASK
);
}
示例13: toDisplayString
public static String toDisplayString(int mods) {
ArrayList<String> arr = new ArrayList<String>();
if ((mods & InputEvent.CTRL_DOWN_MASK) != 0)
arr.add(Strings.get("ctrlMod"));
if ((mods & InputEvent.ALT_DOWN_MASK) != 0)
arr.add(Strings.get("altMod"));
if ((mods & InputEvent.SHIFT_DOWN_MASK) != 0)
arr.add(Strings.get("shiftMod"));
if ((mods & InputEvent.BUTTON1_DOWN_MASK) != 0)
arr.add(Strings.get("button1Mod"));
if ((mods & InputEvent.BUTTON2_DOWN_MASK) != 0)
arr.add(Strings.get("button2Mod"));
if ((mods & InputEvent.BUTTON3_DOWN_MASK) != 0)
arr.add(Strings.get("button3Mod"));
if (arr.isEmpty())
return "";
Iterator<String> it = arr.iterator();
if (it.hasNext()) {
StringBuilder ret = new StringBuilder();
ret.append(it.next());
while (it.hasNext()) {
ret.append(" ");
ret.append(it.next());
}
return ret.toString();
} else {
return "";
}
}
示例14: getCharSequence
public String getCharSequence(String keys) {
StringBuilder sb = new StringBuilder();
if (keys.length() == 1) {
sb.append(keys);
} else {
KeyStrokeParser ksp = new KeyStrokeParser(keys);
KeyStroke ks = ksp.getKeyStroke();
CharSequence keys2 = keyMapping.get(ks.getKeyCode());
if (keys2 == null) {
String keysText = KeyEvent.getKeyText(ks.getKeyCode());
if (keysText.length() == 1 && Character.isUpperCase(keysText.charAt(0))) {
keysText = keysText.toLowerCase();
}
keys2 = keysText;
}
int modifiers = ks.getModifiers();
if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0) {
sb.append(Keys.SHIFT);
}
if ((modifiers & InputEvent.CTRL_DOWN_MASK) != 0) {
sb.append(Keys.CONTROL);
}
if ((modifiers & InputEvent.META_DOWN_MASK) != 0) {
sb.append(Keys.META);
}
if ((modifiers & InputEvent.ALT_DOWN_MASK) != 0) {
sb.append(Keys.ALT);
}
sb.append(keys2);
}
return sb.toString();
}
示例15: convertModifiersToDropAction
public static int convertModifiersToDropAction(final int modifiers,
final int supportedActions) {
int dropAction = DnDConstants.ACTION_NONE;
/*
* Fix for 4285634.
* Calculate the drop action to match Motif DnD behavior.
* If the user selects an operation (by pressing a modifier key),
* return the selected operation or ACTION_NONE if the selected
* operation is not supported by the drag source.
* If the user doesn't select an operation search the set of operations
* supported by the drag source for ACTION_MOVE, then for
* ACTION_COPY, then for ACTION_LINK and return the first operation
* found.
*/
switch (modifiers & (InputEvent.SHIFT_DOWN_MASK |
InputEvent.CTRL_DOWN_MASK)) {
case InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK:
dropAction = DnDConstants.ACTION_LINK; break;
case InputEvent.CTRL_DOWN_MASK:
dropAction = DnDConstants.ACTION_COPY; break;
case InputEvent.SHIFT_DOWN_MASK:
dropAction = DnDConstants.ACTION_MOVE; break;
default:
if ((supportedActions & DnDConstants.ACTION_MOVE) != 0) {
dropAction = DnDConstants.ACTION_MOVE;
} else if ((supportedActions & DnDConstants.ACTION_COPY) != 0) {
dropAction = DnDConstants.ACTION_COPY;
} else if ((supportedActions & DnDConstants.ACTION_LINK) != 0) {
dropAction = DnDConstants.ACTION_LINK;
}
}
return dropAction & supportedActions;
}