Java Code Examples for org.eclipse.swt.SWT#MOD2

The following examples show how to use org.eclipse.swt.SWT#MOD2 . These examples are extracted from open source projects. 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
/**
 * Processes a key stroke while the info popup is up.
 * 
 * @param e
 *            the verify event describing the key stroke
 * @return <code>true</code> if processing can be stopped
 */
private boolean contextInfoPopupKeyPressed(KeyEvent e)
{
	char key = e.character;
	if (key == 0)
	{
		switch (e.keyCode)
		{
			case SWT.ARROW_LEFT:
			case SWT.ARROW_RIGHT:
			case SWT.ARROW_UP:
			case SWT.ARROW_DOWN:
				validateContextInformation();
				break;
			default:
				if (e.keyCode != SWT.CAPS_LOCK && e.keyCode != SWT.MOD1 && e.keyCode != SWT.MOD2
						&& e.keyCode != SWT.MOD3 && e.keyCode != SWT.MOD4)
				{
					hideContextInfoPopup();
				}
				break;
		}

	}
	else if (key == SWT.ESC)
	{
		e.doit = false;
		hideContextInfoPopup();
	}
	else
	{
		validateContextInformation();
	}
	return true;
}
 
Example 2
/**
 * Processes a key stroke in the context selector.
 * 
 * @param e
 *            the verify event describing the key stroke
 * @return <code>true</code> if processing can be stopped
 */
private boolean contextSelectorKeyPressed(VerifyEvent e)
{
	char key = e.character;
	if (key == 0)
	{
		int newSelection = fContextSelectorTable.getSelectionIndex();
		int visibleRows = (fContextSelectorTable.getSize().y / fContextSelectorTable.getItemHeight()) - 1;
		int itemCount = fContextSelectorTable.getItemCount();
		switch (e.keyCode)
		{
			case SWT.ARROW_UP:
				newSelection -= 1;
				if (newSelection < 0)
				{
					newSelection = itemCount - 1;
				}
				break;

			case SWT.ARROW_DOWN:
				newSelection += 1;
				if (newSelection > itemCount - 1)
				{
					newSelection = 0;
				}
				break;

			case SWT.PAGE_DOWN:
				newSelection += visibleRows;
				if (newSelection >= itemCount)
				{
					newSelection = itemCount - 1;
				}
				break;

			case SWT.PAGE_UP:
				newSelection -= visibleRows;
				if (newSelection < 0)
				{
					newSelection = 0;
				}
				break;

			case SWT.HOME:
				newSelection = 0;
				break;

			case SWT.END:
				newSelection = itemCount - 1;
				break;

			default:
				if (e.keyCode != SWT.CAPS_LOCK && e.keyCode != SWT.MOD1 && e.keyCode != SWT.MOD2
						&& e.keyCode != SWT.MOD3 && e.keyCode != SWT.MOD4)
				{
					hideContextSelector();
				}
				return true;
		}

		fContextSelectorTable.setSelection(newSelection);
		fContextSelectorTable.showSelection();
		e.doit = false;
		return false;
	}
	else if ('\t' == key)
	{
		// switch focus to selector shell
		e.doit = false;
		fContextSelectorShell.setFocus();
		return false;
	}
	else if (key == SWT.ESC)
	{
		e.doit = false;
		hideContextSelector();
	}

	return true;
}