当前位置: 首页>>代码示例>>Java>>正文


Java KeyStroke.getModifierKeys方法代码示例

本文整理汇总了Java中org.eclipse.jface.bindings.keys.KeyStroke.getModifierKeys方法的典型用法代码示例。如果您正苦于以下问题:Java KeyStroke.getModifierKeys方法的具体用法?Java KeyStroke.getModifierKeys怎么用?Java KeyStroke.getModifierKeys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jface.bindings.keys.KeyStroke的用法示例。


在下文中一共展示了KeyStroke.getModifierKeys方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: internalMatchesKeybinding

import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
private static boolean internalMatchesKeybinding(int keyCode, int stateMask, TriggerSequence seq)
{
	KeySequence keySequence = (KeySequence) seq;
	KeyStroke[] keyStrokes = keySequence.getKeyStrokes();

	if (keyStrokes.length > 1)
	{
		return false; // Only handling one step binding... the code below does not support things as "CTRL+X R" for
						// redo.
	}
	for (KeyStroke keyStroke : keyStrokes)
	{
		if (keyStroke.getNaturalKey() == keyCode && keyStroke.getModifierKeys() == stateMask)
		{

			return true;
		}
	}
	return false;
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:21,代码来源:KeyBindingHelper.java

示例2: format

import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
public String format(final KeyStroke keyStroke) {
	final String keyDelimiter = getKeyDelimiter();

	// Format the modifier keys, in sorted order.
	final int modifierKeys = keyStroke.getModifierKeys();
	final int[] sortedModifierKeys = sortModifierKeys(modifierKeys);
	final StringBuffer stringBuffer = new StringBuffer();
	if (sortedModifierKeys != null) {
		for (int i = 0; i < sortedModifierKeys.length; i++) {
			final int modifierKey = sortedModifierKeys[i];
			if (modifierKey != KeyStroke.NO_KEY) {
				stringBuffer.append(format(modifierKey));
				stringBuffer.append(keyDelimiter);
			}
		}
	}

	// Format the natural key, if any.
	final int naturalKey = keyStroke.getNaturalKey();
	if (naturalKey != 0) {
		stringBuffer.append(format(naturalKey));
	}

	return stringBuffer.toString();

}
 
开发者ID:ghillairet,项目名称:gef-gwt,代码行数:27,代码来源:AbstractKeyFormatter.java

示例3: countStrokes

import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
/**
 * Returns the number of strokes in an array of triggers. It is assumed that
 * there is one natural key per trigger. The strokes are counted based on
 * the type of key. Natural keys are worth one; ctrl is worth two; shift is
 * worth four; and alt is worth eight.
 * 
 * @param triggers
 *            The triggers on which to count strokes; must not be
 *            <code>null</code>.
 * @return The value of the strokes in the triggers.
 * @since 3.2
 */
private final int countStrokes(final Trigger[] triggers) {
	int strokeCount = triggers.length;
	for (int i = 0; i < triggers.length; i++) {
		final Trigger trigger = triggers[i];
		if (trigger instanceof KeyStroke) {
			final KeyStroke keyStroke = (KeyStroke) trigger;
			final int modifierKeys = keyStroke.getModifierKeys();
			final IKeyLookup lookup = KeyLookupFactory.getDefault();
			if ((modifierKeys & lookup.getAlt()) != 0) {
				strokeCount += 8;
			}
			if ((modifierKeys & lookup.getCtrl()) != 0) {
				strokeCount += 2;
			}
			if ((modifierKeys & lookup.getShift()) != 0) {
				strokeCount += 4;
			}
			if ((modifierKeys & lookup.getCommand()) != 0) {
				strokeCount += 2;
			}
		} else {
			strokeCount += 99;
		}
	}

	return strokeCount;
}
 
开发者ID:ghillairet,项目名称:gef-gwt,代码行数:40,代码来源:BindingManager.java

示例4: getShifted

import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
/**
 * Does the trigger for this movement command contain the SHIFT key?
 * 
 * Enforce that the <binding> and <binding>+SHIFT belong to the same Command. 
 * If not, don't apply shift selection (if enabled) for this command (i.e. return false).
 *  
 * @param event the Execution event that invoked this command
 * 
 * @return true if SHIFT modifier was set, else false
 */
private boolean getShifted(ExecutionEvent event) {
	// NB: only single keystroke commands are valid 
	boolean result = false;
	Object trigger = event.getTrigger();
	Event e = null;
	if (trigger != null && trigger instanceof Event && ((e = (Event)trigger).stateMask & SWT.SHIFT )!= 0) {
		String cmdId = event.getCommand().getId();
		int mask = (e.stateMask & SWT.MODIFIER_MASK) ^ SWT.SHIFT;
		int u_code = Character.toUpperCase((char)e.keyCode);
		IBindingService bs = (IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class);
		if (cmdId != null && bs != null) {
			TriggerSequence[] sequences = bs.getActiveBindingsFor(cmdId);
			for (TriggerSequence s : sequences) {
				if (s instanceof KeySequence) {
					KeyStroke[] strokes = ((KeySequence)s).getKeyStrokes();
					if (strokes.length == 1) {
						KeyStroke k = strokes[strokes.length - 1];
						// if keyCode is alpha, then we test uppercase, else keyCode
						if (k.getModifierKeys() == mask
								&& (k.getNaturalKey() == u_code || k.getNaturalKey() == e.keyCode)) {
							result = true;
							break;
						}
					}
				}
			}
		} 
	}
	return result;
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:41,代码来源:EmacsMovementHandler.java

示例5: makeEvent

import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
private Event makeEvent(IUniversalResult ua) {
	Event result = new Event();
	KeySequence keys = ua.getTrigger();
	if (keys != null) {
		Trigger[] triggers = keys.getTriggers();
		if (triggers[0] instanceof KeyStroke) {	// really, all it can be anyway
			KeyStroke ks = (KeyStroke)triggers[triggers.length - 1];
			result.keyCode = ks.getNaturalKey();
			result.stateMask = ks.getModifierKeys() & SWT.MODIFIER_MASK;
		}
	}
	return result;
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:14,代码来源:UniversalHandler.java

示例6: matchesKeybinding

import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
public static boolean matchesKeybinding(int keyCode, int stateMask, KeySequence keySequence) {
    KeyStroke[] keyStrokes = keySequence.getKeyStrokes();

    for (KeyStroke keyStroke : keyStrokes) {

        if (keyStroke.getNaturalKey() == keyCode
                && ((keyStroke.getModifierKeys() & stateMask) != 0 || keyStroke.getModifierKeys() == stateMask)) {

            return true;
        }
    }
    return false;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:14,代码来源:KeyBindingHelper.java

示例7: getKeyCode

import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
private int getKeyCode(final KeySequence inSequence) {
	int out = 0;
	for (final KeyStroke lStroke : inSequence.getKeyStrokes()) {
		out |= lStroke.getModifierKeys() | lStroke.getNaturalKey();
	}
	return out;
}
 
开发者ID:aktion-hip,项目名称:relations,代码行数:8,代码来源:AbstractEditFormTest.java

示例8: getKeyCode

import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
private int getKeyCode(final KeySequence inSequence) {
	int out = 0;
	if (inSequence == null) {
		return out;
	}
	for (final KeyStroke lStroke : inSequence.getKeyStrokes()) {
		out |= lStroke.getModifierKeys() | lStroke.getNaturalKey();
	}
	return out;
}
 
开发者ID:aktion-hip,项目名称:relations,代码行数:11,代码来源:AbstractEditForm.java

示例9: handleVerifyKeyPressed

import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
private void handleVerifyKeyPressed(VerifyEvent event) {
	if (!event.doit) {
		return;
	}
	try {
		KeyStroke triggerKeyStroke = HotKeyUtil.getHotKey(HotKeyUtil.contentAssist);
		if (triggerKeyStroke != null) {

			if ((triggerKeyStroke.getModifierKeys() == KeyStroke.NO_KEY && triggerKeyStroke.getNaturalKey() == event.character)
					||
					(((triggerKeyStroke.getNaturalKey() == event.keyCode)
							|| (Character.toLowerCase(triggerKeyStroke.getNaturalKey()) == event.keyCode) || (Character
									.toUpperCase(triggerKeyStroke.getNaturalKey()) == event.keyCode)) && ((triggerKeyStroke
											.getModifierKeys() & event.stateMask) == triggerKeyStroke.getModifierKeys()))) {

				doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
				event.doit = false;
				return;
			}
		}
	} 
	catch (Exception e) {
	}

	if (event.stateMask != SWT.CTRL) {
		return;
	}

	switch (event.character) {
	case ' ':
		doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
		event.doit = false;
		break;

	case '.':
		doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
		event.doit = false;
		break;
	case 'y' - 'a' + 1:
		doOperation(ITextOperationTarget.REDO);
	event.doit = false;
	break;
	case 'z' - 'a' + 1:
		doOperation(ITextOperationTarget.UNDO);
	event.doit = false;
	break;
	default:
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:50,代码来源:SourceViewer.java

示例10: matches

import org.eclipse.jface.bindings.keys.KeyStroke; //导入方法依赖的package包/类
/**
 * Checks whether the given KeyEvent matches the given KeyStroke.
 * @param e The KeyEvent.
 * @param trigger The KeyStroke
 * @return Whether the given event matches the given trigger.
 */
private static boolean matches(KeyEvent e, KeyStroke trigger) {
	return trigger != null && trigger.getModifierKeys() == e.stateMask
			&& Character.toLowerCase((char)trigger.getNaturalKey()) == Character.toLowerCase((char)e.keyCode);
}
 
开发者ID:jgalenson,项目名称:codehint,代码行数:11,代码来源:SynthesisDialog.java


注:本文中的org.eclipse.jface.bindings.keys.KeyStroke.getModifierKeys方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。