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

The following examples show how to use org.eclipse.swt.SWT#ESC . 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
/**
 * Installs all display listeners.
 */
private void installDisplayListeners() {
	//Sanity check
	deinstallDisplayListeners();

	fDisplayKeyListener= new Listener() {
		public void handleEvent(Event event) {
			if (event.keyCode != SWT.ESC)
				return;

			if (!isBreadcrumbEvent(event))
				return;

			fTextViewer.getTextWidget().setFocus();
		}
	};
	Display.getDefault().addFilter(SWT.KeyDown, fDisplayKeyListener);
}
 
Example 2
Source Project: nebula   File: TextAssist.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @return a listener for the keydown event
 */
private Listener createKeyDownListener() {
	return new Listener() {
		@Override
		public void handleEvent(final Event event) {
			switch (event.keyCode) {
				case SWT.ARROW_DOWN:
					int index = (table.getSelectionIndex() + 1) % table.getItemCount();
					table.setSelection(index);
					event.doit = false;
					break;
				case SWT.ARROW_UP:
					index = table.getSelectionIndex() - 1;
					if (index < 0) {
						index = table.getItemCount() - 1;
					}
					table.setSelection(index);
					event.doit = false;
					break;
				case SWT.CR:
				case SWT.KEYPAD_CR:
					if (popup.isVisible() && table.getSelectionIndex() != -1) {
						text.setText(table.getSelection()[0].getText());
						popup.setVisible(false);
					}
					break;
				case SWT.ESC:
					popup.setVisible(false);
					break;
			}
		}
	};
}
 
Example 3
protected void pressKey(XtextEditor editor, char c) throws Exception {
	StyledText textWidget = editor.getInternalSourceViewer().getTextWidget();
	Event e = new Event();
	e.character = c;
	e.type = SWT.KeyDown;
	e.doit = true;
	//XXX Hack!
	if (c == SWT.ESC) {
		e.keyCode = 27;
	}
	textWidget.notifyListeners(SWT.KeyDown, e);
}
 
Example 4
protected void pressKey(XtextEditor editor, char c) throws Exception {
	StyledText textWidget = editor.getInternalSourceViewer().getTextWidget();
	Event e = new Event();
	e.character = c;
	e.type = SWT.KeyDown;
	e.doit = true;
	//XXX Hack!
	if (c == SWT.ESC) {
		e.keyCode = 27;
	}
	textWidget.notifyListeners(SWT.KeyDown, e);
}
 
Example 5
private void processKeyDown( int keyCode )
{
	switch ( keyCode )
	{
		case SWT.ESC :
			break;
		case SWT.CR :
		case SWT.KEYPAD_CR :
			doToggleDropDown( );
			break;
		case SWT.HOME :
			select( 0 );
			break;
		case SWT.END :
			select( context.getBitmaps( ).size( ) - 1 );
			break;
		case SWT.ARROW_LEFT :
			select( context.getIndex( ) - 1 );
			break;
		case SWT.ARROW_RIGHT :
			select( context.getIndex( ) + 1 );
			break;
		case SWT.ARROW_UP :
			select( context.getIndex( ) - columns );
			break;
		case SWT.ARROW_DOWN :
			select( context.getIndex( ) + columns );
			break;
	}

}
 
Example 6
@Override
public void handleEvent(Event event) {
    switch (event.type) {
        case SWT.Activate:
        case SWT.MouseVerticalWheel:
        case SWT.MouseUp:
        case SWT.MouseDown:
        case SWT.FocusOut:
            IInformationControl iControl = fInformationControl;
            if (iControl != null && !iControl.isFocusControl()) {
                hideInformationControl();
            }
            break;

        case SWT.MouseMove:
        case SWT.MouseEnter:
        case SWT.MouseExit:
            handleMouseMove(event);
            break;

        case SWT.KeyDown:
            if (event.keyCode == SWT.ESC) {
                hideInformationControl();

            } else if (fActivateEditorBinding != null
                    && KeyBindingHelper.matchesKeybinding(event.keyCode, event.stateMask,
                            fActivateEditorBinding)) {
                hideInformationControl(true, true);
            }
            break;
    }
}
 
Example 7
private void processKeyDown( int keyCode )
{
	switch ( keyCode )
	{
		case SWT.ESC :
			onDropDonwFocusOut( );
			break;
		case SWT.CR :
		case SWT.KEYPAD_CR :
			toggleCell( iRowAct, iColAct );
			break;
		case SWT.HOME :
			moveTo( 0, 0 );
			dropDown.redraw( );
			break;
		case SWT.END :
			moveTo( 7, 7 );
			dropDown.redraw( );
			break;
		case SWT.ARROW_LEFT :
			moveTo( iRowAct, iColAct - 1 );
			dropDown.redraw( );
			break;
		case SWT.ARROW_RIGHT :
			moveTo( iRowAct, iColAct + 1 );
			dropDown.redraw( );
			break;
		case SWT.ARROW_UP :
			moveTo( iRowAct - 1, iColAct );
			dropDown.redraw( );
			break;
		case SWT.ARROW_DOWN :
			moveTo( iRowAct + 1, iColAct );
			dropDown.redraw( );
			break;
	}

}
 
Example 8
Source Project: hop   File: HopGui.java    License: Apache License 2.0 4 votes vote down vote up
@GuiMenuElement( root = ID_MAIN_MENU, id = ID_MAIN_MENU_EDIT_UNSELECT_ALL, label = "Clear selection", parentId = ID_MAIN_MENU_EDIT_PARENT_ID )
@GuiKeyboardShortcut( key = SWT.ESC )
@GuiOsxKeyboardShortcut( key = SWT.ESC )
public void menuEditUnselectAll() {
  getActiveFileTypeHandler().unselectAll();
}
 
Example 9
Source Project: hop   File: HopGuiPipelineGraph.java    License: Apache License 2.0 4 votes vote down vote up
@GuiKeyboardShortcut( key = SWT.ESC )
@Override public void unselectAll() {
  clearSettings();
  updateGui();
}
 
Example 10
Source Project: hop   File: HopGuiWorkflowGraph.java    License: Apache License 2.0 4 votes vote down vote up
@GuiKeyboardShortcut( key = SWT.ESC )
@Override public void unselectAll() {
  clearSettings();
  updateGui();
}
 
Example 11
Source Project: hop   File: GuiMenuWidgets.java    License: Apache License 2.0 4 votes vote down vote up
public static String getShortcutString( KeyboardShortcut shortcut ) {
  String s = shortcut.toString();
  if ( StringUtils.isEmpty( s ) || s.endsWith( "-" ) ) {
    // Unknown characters from the SWT library
    // We'll handle the special cases here.
    //
    int keyCode = shortcut.getKeyCode();
    if ( keyCode == SWT.BS ) {
      return s + "Backspace";
    }
    if ( keyCode == SWT.ESC ) {
      return s + "Esc";
    }
    if ( keyCode == SWT.ARROW_LEFT ) {
      return s + "LEFT";
    }
    if ( keyCode == SWT.ARROW_RIGHT ) {
      return s + "RIGHT";
    }
    if ( keyCode == SWT.ARROW_UP ) {
      return s + "UP";
    }
    if ( keyCode == SWT.ARROW_DOWN ) {
      return s + "DOWN";
    }
    if ( keyCode == SWT.HOME ) {
      return s + "HOME";
    }
    if ( keyCode == SWT.F1 ) {
      return s + "F1";
    }
    if ( keyCode == SWT.F2 ) {
      return s + "F2";
    }
    if ( keyCode == SWT.F3 ) {
      return s + "F3";
    }
    if ( keyCode == SWT.F4 ) {
      return s + "F4";
    }
    if ( keyCode == SWT.F5 ) {
      return s + "F5";
    }
    if ( keyCode == SWT.F6 ) {
      return s + "F6";
    }
    if ( keyCode == SWT.F7 ) {
      return s + "F7";
    }
    if ( keyCode == SWT.F8 ) {
      return s + "F8";
    }
    if ( keyCode == SWT.F9 ) {
      return s + "F9";
    }
    if ( keyCode == SWT.F10 ) {
      return s + "F10";
    }
    if ( keyCode == SWT.F11 ) {
      return s + "F11";
    }
    if ( keyCode == SWT.F12 ) {
      return s + "F12";
    }
  }
  return s;
}
 
Example 12
/**
 * Add key listeners
 */
private void addKeyListeners() {
	keyListener = new KeyAdapter() {

		/**
		 * @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent)
		 */
		@Override
		public void keyPressed(final KeyEvent e) {
			switch (e.character) {
				case '0':
				case '1':
				case '2':
				case '3':
				case '4':
				case '5':
				case '6':
				case '7':
				case '8':
				case '9':
					behaviourEngine.addDigitToDisplay(Integer.parseInt(String.valueOf(e.character)));
					return;
				case '.':
					behaviourEngine.addDecimalPoint();
					return;
				case '+':
					engine.processOperation(CalculatorEngine.OPERATOR_PLUS);
					return;
				case '-':
					engine.processOperation(CalculatorEngine.OPERATOR_MINUS);
					return;
				case '*':
					engine.processOperation(CalculatorEngine.OPERATOR_MULTIPLY);
					return;
				case '/':
					engine.processOperation(CalculatorEngine.OPERATOR_DIVIDE);
					return;
				case '=':
					engine.processEquals();
					return;
				case '%':
					engine.processPerCentageOperation();
					return;

			}

			switch (e.keyCode) {
				case SWT.KEYPAD_0:
				case SWT.KEYPAD_1:
				case SWT.KEYPAD_2:
				case SWT.KEYPAD_3:
				case SWT.KEYPAD_4:
				case SWT.KEYPAD_5:
				case SWT.KEYPAD_6:
				case SWT.KEYPAD_7:
				case SWT.KEYPAD_8:
				case SWT.KEYPAD_9:
					final int digit = e.keyCode - SWT.KEYCODE_BIT - 47;
					behaviourEngine.addDigitToDisplay(digit);
					return;
				case SWT.KEYPAD_ADD:
					engine.processOperation(CalculatorEngine.OPERATOR_PLUS);
					return;
				case SWT.KEYPAD_SUBTRACT:
					engine.processOperation(CalculatorEngine.OPERATOR_MINUS);
					return;
				case SWT.KEYPAD_DIVIDE:
					engine.processOperation(CalculatorEngine.OPERATOR_DIVIDE);
					return;
				case SWT.KEYPAD_MULTIPLY:
					engine.processOperation(CalculatorEngine.OPERATOR_MULTIPLY);
					return;
				case SWT.KEYPAD_CR:
				case SWT.KEYPAD_EQUAL:
				case SWT.CR:
					engine.processEquals();
					return;
				case SWT.BS:
					behaviourEngine.processBackSpace();
					return;
				case SWT.ESC:
					behaviourEngine.clearResult();
					engine.cancel();
					return;
			}
		}
	};

	for (final Control control : getChildren()) {
		control.addKeyListener(keyListener);
	}
	addKeyListener(keyListener);

}
 
Example 13
Source Project: nebula   File: CDateTime.java    License: Eclipse Public License 2.0 4 votes vote down vote up
/**
 * The Key event handler
 * 
 * @param event
 *            the event
 */
void handleKey(Event event) {
	if (event.stateMask != 0 && event.stateMask != SWT.SHIFT) {
		return;
	}
	if ('\r' == event.keyCode || SWT.KEYPAD_CR == event.keyCode) {
		fieldNext();
		fireSelectionChanged(true);
	} else if (SWT.BS == event.keyCode || SWT.DEL == event.keyCode) {
		event.doit = false;
		setSelection((Date) null);
		fireSelectionChanged();
	} else if (!hasField(activeField) && !hasSelection()) {
		event.doit = false;
	} else {
		switch (event.keyCode) {
		case '-':
		case SWT.KEYPAD_SUBTRACT:
			fieldAdjust(-1);
			break;
		case '=':
		case '+':
		case SWT.KEYPAD_ADD:
			fieldAdjust(1);
			break;
		case SWT.BS:
			if (editField != null) {
				editField.removeLastCharacter();
			}
			break;
		case SWT.CR:
			fieldNext();
			fireSelectionChanged();
			break;
		case SWT.ARROW_DOWN:
			fieldAdjust(-1);
			updateText(true);
			break;
		case SWT.ARROW_UP:
			fieldAdjust(1);
			updateText(true);
			break;
		case SWT.ARROW_LEFT:
			fieldPrev(true);
			break;
		case SWT.ARROW_RIGHT:
			fieldNext(true);
			break;
		case SWT.ESC:
			if (contentShell != null) {
				event.doit = false;
				if (selection.length > 0 && selection[0] != cancelDate) {
					setSelection(cancelDate);
					fireSelectionChanged();
				}
				setOpen(false);
			}
			break;
		default:
			if (hasField(activeField) && activeField + 1 < separator.length
					&& String.valueOf(event.character)
							.equals(separator[activeField + 1])) {
				fieldNext();
			} else if (!hasSelection()
					&& String.valueOf(event.character).matches("[0-9]")) { //$NON-NLS-1$
				fieldAdjust(0);
				fieldFirst();
			}
		}
	}
}
 
Example 14
void handleEventCanvasMarkers( Event event )
{
	switch ( event.type )
	{
		case SWT.KeyDown :
		{
			if ( event.keyCode == SWT.ARROW_LEFT )
			{
				if ( iSelectedIndex - 1 >= 0 )
				{
					iSelectedIndex--;
					setEnabledState( );
				}
			}
			else if ( event.keyCode == SWT.ARROW_RIGHT )
			{
				if ( iSelectedIndex + 1 < getMarkers( ).size( ) )
				{
					iSelectedIndex++;
					setEnabledState( );
				}
			}
			else if ( event.keyCode == SWT.ARROW_UP )
			{
				if ( iSelectedIndex - MARKER_ROW_MAX_NUMBER >= 0 )
				{
					iSelectedIndex -= MARKER_ROW_MAX_NUMBER;
					setEnabledState( );
				}
			}
			else if ( event.keyCode == SWT.ARROW_DOWN )
			{
				if ( iSelectedIndex + MARKER_ROW_MAX_NUMBER < getMarkers( ).size( ) )
				{
					iSelectedIndex += MARKER_ROW_MAX_NUMBER;
					setEnabledState( );
				}
			}
			
			else if ( event.keyCode == SWT.CR
					|| event.keyCode == SWT.KEYPAD_CR )
			{
				currentMarkerEditor.setFocus( );
			}
			else if ( event.keyCode == SWT.ESC )
			{
				cnvMarkers.getShell( ).close( );
			}
			break;
		}
		case SWT.Traverse :
		{
			switch ( event.detail )
			{
				case SWT.TRAVERSE_RETURN :
				case SWT.TRAVERSE_TAB_NEXT :
				case SWT.TRAVERSE_TAB_PREVIOUS :
				case SWT.TRAVERSE_ARROW_PREVIOUS :
				case SWT.TRAVERSE_ARROW_NEXT :
					event.doit = true;
					cnvMarkers.redraw( );
			}
			break;
		}
		case SWT.Paint :
			paintControl( new PaintEvent( event ) );
			break;
		case SWT.MouseDown :
			mouseDown( new MouseEvent( event ) );
			break;
	}
}
 
Example 15
private void onKeyDown(KeyEvent e){
	if (e.character == SWT.ESC) {
		onDateSelected(false);
		return;
	}
	
	if ((e.character == ' ') || (e.character == '\r')) {
		onDateSelected(true);
		return;
	}
	
	int day = cal.get(Calendar.DAY_OF_MONTH);
	int month = cal.get(Calendar.MONTH);
	int oldDay = day;
	int oldMonth = month;
	
	if (e.keyCode == SWT.ARROW_LEFT) {
		day--;
	}
	
	if (e.keyCode == SWT.ARROW_RIGHT) {
		day++;
	}
	
	if (e.keyCode == SWT.ARROW_UP) {
		day = ((day - 7) < 1 ? oldDay : day - 7);
	}
	
	if (e.keyCode == SWT.ARROW_DOWN) {
		day = ((day + 7) > getMaxDay() ? oldDay : day + 7);
	}
	
	if (e.keyCode == SWT.PAGE_UP) {
		month--;
	}
	
	if (e.keyCode == SWT.PAGE_DOWN) {
		month++;
	}
	
	cal.set(Calendar.MONTH, month);
	cal.set(Calendar.DAY_OF_MONTH, day);
	
	if ((day != oldDay) || (month != oldMonth)) {
		redraw();
		
		if (month != oldMonth) {
			updateMonthLabel();
		}
	}
}
 
Example 16
@Override
public void handleEvent(final Event event) {
	if (event.keyCode == SWT.ESC) {
		if (GAMA.getGui().toggleFullScreenMode()) {
			consume(event);
		}
		return;
	}
	if (event.stateMask == 0) { return; }

	switch (event.keyCode) {

		case 'h':
			if (ctrl(event) && shift(event)) {
				consume(event);
				GamlSearchField.INSTANCE.search();
			}
			break;
		// Handles START, PAUSE & STEP
		case 'p':
			if (ctrl(event) && shift(event)) {
				consume(event);
				GAMA.stepFrontmostExperiment();
			} else if (ctrl(event)) {
				consume(event);
				GAMA.startPauseFrontmostExperiment();
			}
			break;
		// Handles RELOAD & RELAUNCH
		case 'r': {
			if (PerspectiveHelper.isModelingPerspective()) {
				// See Issue #2741
				break;
			}
			if (ctrl(event) && shift(event)) {
				// DEBUG.OUT("SHIFT CONTROL R Pressed");
				consume(event);
				GAMA.relaunchFrontmostExperiment();
			} else if (ctrl(event)) {
				// DEBUG.OUT("CONTROL R Pressed");
				consume(event);
				GAMA.reloadFrontmostExperiment();
			}
			break;
		}
		// Handles CLOSE
		case 'x':
			if (ctrl(event) && shift(event)) {
				consume(event);
				GAMA.closeAllExperiments(true, false);
			}
			break;
		default:
			// DEBUG.LOG(" KEY CODE " + event.keyCode + " MODS " + event.stateMask);
			final PluggableBinding pb = bindings.get(KeyStroke.getInstance(event.stateMask, event.keyCode));
			if (pb != null) {
				consume(event);
				pb.run();
			}
	}

}
 
Example 17
/**
 * 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;
}
 
Example 18
public void handleEvent( Event event )
{
	switch ( event.type )
	{
		case SWT.FocusOut :
			focusLost( new FocusEvent( event ) );
			break;

		case SWT.FocusIn:
			focusedComposite = event.widget;
			break;
			
		case SWT.MouseDown :
			mouseDown( new MouseEvent( event ) );
			break;

		case SWT.Selection :
			widgetSelected( new SelectionEvent( event ) );
			break;

		case SWT.KeyDown :
			if ( event.keyCode == SWT.ESC )
			{
				getShell( ).close( );
			}
			else if ( event.widget == cmpType )
			{
				int newIndex;
				if ( event.keyCode == SWT.ARROW_LEFT )
				{
					if ( markerTypeIndex - 1 >= 0 )
					{
						newIndex = markerTypeIndex - 1;
						switchMarkerType( newIndex );
						redrawMarkers( newIndex );
					}
				}
				else if ( event.keyCode == SWT.ARROW_RIGHT )
				{
					if ( markerTypeIndex + 1 < typeNameSet.length )
					{
						newIndex = markerTypeIndex + 1;
						switchMarkerType( newIndex );
						redrawMarkers( newIndex );
					}
				}
				else if ( event.keyCode == SWT.ARROW_UP )
				{
					if ( markerTypeIndex - MARKER_ROW_MAX_NUMBER >= 0 )
					{
						newIndex = markerTypeIndex
								- MARKER_ROW_MAX_NUMBER;
						switchMarkerType( newIndex );
						redrawMarkers( newIndex );
					}
				}
				else if ( event.keyCode == SWT.ARROW_DOWN )
				{
					if ( markerTypeIndex + MARKER_ROW_MAX_NUMBER < typeNameSet.length )
					{
						newIndex = markerTypeIndex
								+ MARKER_ROW_MAX_NUMBER;
						switchMarkerType( newIndex );
						redrawMarkers( newIndex );
					}
				}
			}
			break;

		case SWT.Traverse :
			// Indicates getting focus control rather than
			// cursor control
			if ( event.detail == SWT.TRAVERSE_TAB_NEXT
					|| event.detail == SWT.TRAVERSE_TAB_PREVIOUS )
			{
				event.doit = true;
				isPressingKey = true;
			}
			else if ( event.keyCode == getMnemonicByText( grpSize.getText( ) ) )
			{
				updateIsPressingKey( iscMarkerSize );
			}
			else if ( event.keyCode == getMnemonicByText( btnOutline.getButton( )
					.getText( ) ) )
			{
				updateIsPressingKey( btnOutline );
			}
			else if ( event.keyCode == getMnemonicByText( btnMarkerVisible.getButton( )
					.getText( ) ) )
			{
				updateIsPressingKey( btnMarkerVisible );
			}
	}
}
 
Example 19
public void keyPressed( KeyEvent e )
{
	switch ( e.keyCode )
	{
		case SWT.ARROW_DOWN :
			if ( iSelectedIndex < elPaletteEntries1.size( ) - 1 )
			{
				iSelectedIndex++;
				scrollToView( iSelectedIndex );
				coPaletteEntries.redraw( );
			}
			break;
		case SWT.ARROW_UP :
			if ( iSelectedIndex > 0 )
			{
				iSelectedIndex--;
				scrollToView( iSelectedIndex );
				coPaletteEntries.redraw( );
			}
			break;
		case SWT.CR :
			if ( coPaletteEntries.isFocusControl( ) )
			{
				coEditor.setFocus( );
			}
			break;
		case SWT.PAGE_DOWN :
			iSelectedIndex += 8;
			if ( iSelectedIndex > elPaletteEntries1.size( ) )
			{
				iSelectedIndex = elPaletteEntries1.size( ) - 1;
			}
			scrollToView( iSelectedIndex );
			sb.setSelection( sb.getMaximum( )
					* ( iSelectedIndex + 1 )
					/ elPaletteEntries1.size( ) );
			coPaletteEntries.redraw( );
			break;
		case SWT.PAGE_UP :
			iSelectedIndex -= 8;
			if ( iSelectedIndex < 0 )
			{
				iSelectedIndex = 0;
			}
			scrollToView( iSelectedIndex );
			sb.setSelection( sb.getMaximum( )
					* iSelectedIndex
					/ elPaletteEntries1.size( ) );
			coPaletteEntries.redraw( );
			break;
		case SWT.TAB :
			btnAdd.setFocus( );
			break;
		case SWT.ESC :
			this.getShell( ).close( );
			break;
	}
}
 
Example 20
void keyDown( Event event )
{
	if ( event.keyCode == SWT.ESC )
	{
		cmpDropDown.getShell( ).close( );
		return;
	}
	if ( selectedIndex == -1 )
	{
		if ( event.keyCode == SWT.ARROW_LEFT
				|| event.keyCode == SWT.ARROW_RIGHT
				|| event.keyCode == SWT.ARROW_UP
				|| event.keyCode == SWT.ARROW_DOWN )
		{
			selectedIndex = 0;
		}
	}
	else
	{
		switch ( event.keyCode )
		{
			case SWT.ARROW_LEFT :
				if ( selectedIndex - 1 >= 0 )
				{
					selectedIndex -= 1;
				}
				break;
			case SWT.ARROW_RIGHT :
				if ( selectedIndex + 1 < ROW_SIZE * COLUMN_SIZE )
				{
					selectedIndex += 1;
				}
				break;
			case SWT.ARROW_UP :
				if ( selectedIndex - ROW_SIZE >= 0 )
				{
					selectedIndex -= ROW_SIZE;
				}
				break;
			case SWT.ARROW_DOWN :
				if ( selectedIndex + ROW_SIZE < ROW_SIZE * COLUMN_SIZE )
				{
					selectedIndex += ROW_SIZE;
				}
				break;
			case SWT.CR :
			case SWT.KEYPAD_CR :
				setColorToModel( colorMap[selectedIndex] );
				cmpDropDown.getShell( ).close( );
				break;
		}
	}
	if ( !cmpDropDown.isDisposed( ) )
	{
		colorSelection = null;
		redraw( );
	}
}