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

The following examples show how to use org.eclipse.swt.SWT#KEYPAD_CR . 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
Source File: ChatControl.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
  switch (e.keyCode) {
    case SWT.CR:
    case SWT.KEYPAD_CR:
      String message = getInputText().trim();

      if (message.length() > 0) {
        ChatControl.this.notifyMessageEntered(message);

        sendMessage(message);
      }

      e.doit = false;
  }
}
 
Example 2
Source File: DatePicker.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void setSelectionFromFocusButton(Event event) {
    int fb = getFocusDayButton();
    if (fb >= 0 && fb < dayButtons.length) {
        VButton button = dayButtons[fb];
        int stateMask = event.stateMask;
        setSelectionFromButton(button, stateMask);
        boolean defaultSelection = false;
        if (event.type == SWT.KeyDown && event.stateMask == 0) {
            if (event.keyCode == SWT.KEYPAD_CR
                    || event.character == SWT.CR) {
                defaultSelection = true;
            }
        } else if (event.type == SWT.Traverse && event.stateMask == 0) {
            if (event.keyCode == SWT.TRAVERSE_RETURN) {
                defaultSelection = true;
            }
        }
        cdt.fireSelectionChanged(defaultSelection);
    }
}
 
Example 3
Source File: ChartExpressionButton.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void handleEvent( Event event )
{
	switch ( event.type )
	{
		case SWT.KeyDown :
			if ( event.keyCode == SWT.CR
					|| event.keyCode == SWT.KEYPAD_CR )
			{
				onChange( );
			}
			break;
		case SWT.FocusOut :
		case SWT.Selection :
			onChange( );
			break;
	}
}
 
Example 4
Source File: TextEditorComposite.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void keyPressed( KeyEvent e )
{
	if ( e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR )
	{
		if ( bTextModified )
		{
			fireEvent( );
		}
	}
	else if ( e.keyCode == SWT.ARROW_DOWN || e.keyCode == SWT.ARROW_UP )
	{
		Event event = new Event();
		event.keyCode = e.keyCode;
		event.stateMask = e.stateMask;
		this.notifyListeners( SWT.KeyDown, event );
	}
}
 
Example 5
Source File: TextAssist.java    From nebula with 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 6
Source File: NebulaToolbar.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Handles key released event.
 * 
 * @param e KeyEvent
 */
private void handleKeyReleased(KeyEvent e)
{
	if (selectedItemIndex == -1)
	{
		return;
	}

	if (e.keyCode == ' ' || e.keyCode == SWT.CR || e.keyCode == SWT.LF || e.keyCode == SWT.KEYPAD_CR)
	{
		items[selectedItemIndex].setPushedDown(false);
		items[selectedItemIndex].setHovered(false);

		redraw();

		SelectionListener selectionListener = items[selectedItemIndex].getSelectionListener();

		if (selectionListener == null)
		{
			return;
		}

		Event event = new Event();
		event.widget = this;

		selectionListener.widgetSelected(new SelectionEvent(event));
	}
}
 
Example 7
Source File: ExecuteCommandPopup.java    From EasyShell with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
    if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
        executeCommandFromList(-1);
    } else if (((e.stateMask & SWT.ALT) == 0) && ((e.stateMask & SWT.CTRL) == 0) && ((e.stateMask & SWT.SHIFT) == 0)) {
        if(e.keyCode >= '0' && e.keyCode <= '9') { //check digit
            executeCommandFromList(e.keyCode - '0');
        } else if(e.keyCode >= 'a' && e.keyCode <= 'z') { //check character
            executeCommandFromList((e.keyCode - 'a') + ('9' - '0' + 1));
        }
    } else {
        //Activator.logError("keyPressed", null);
    }
}
 
Example 8
Source File: SimpleConfigurator.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected Control createDialogArea(final Composite parent) {
	final Composite parentPanel = (Composite) super.createDialogArea(parent);
	setLayout(parentPanel);
	// ensure vertical layout
	((RowLayout) parentPanel.getLayout()).type = SWT.VERTICAL;
	((RowLayout) parentPanel.getLayout()).spacing = 3;

	final KeyAdapter adp = new KeyAdapter() {

		@Override
		public void keyReleased(final KeyEvent e) {
			/*
			 * I don't like having different ways of checking for keypad enter and the normal one. Using the keyCode
			 * would be better, but I couldn't readily find the value for CR.
			 */
			if (e.keyCode == SWT.KEYPAD_CR || e.character == SWT.CR) {
				refresh(); // makeActionDoStuff();
			}
		}
	};

	this.line.createControl(parentPanel, adp);
	this.fill.createControl(parentPanel, adp);
	this.point.createControl(parentPanel, adp, this.build);
	// this.label.createControl(parentPanel, adp);
	// this.minScale.createControl(parentPanel, adp);
	// this.maxScale.createControl(parentPanel, adp);

	final Composite replaceComp = subpart(parentPanel, "Replace");
	this.replace = new Button(replaceComp, SWT.CHECK);
	replace.addSelectionListener(synchronize);
	replace.setSelection(true);

	refresh();

	return parentPanel;
}
 
Example 9
Source File: LocalizedNumberEditorComposite.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void keyPressed( KeyEvent e )
{
	if ( e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR )
	{
		if ( bTextModified )
		{
			bTextModified = false;
			fireEvent( );
		}
	}
}
 
Example 10
Source File: PatternImageEditorDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
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 11
Source File: LabResultEditingSupport.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
protected void setUpCellEditor(ColumnViewer viewer){
	// set up validation of the cell editors
	textCellEditor = new TextCellEditor((Composite) viewer.getControl());
	
	textCellEditor.addListener(new ICellEditorListener() {
		@Override
		public void editorValueChanged(boolean oldValidState, boolean newValidState){
			if (newValidState) {
				textCellEditor.getControl()
					.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
			} else {
				textCellEditor.getControl()
					.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
			}
		}
		
		@Override
		public void cancelEditor(){
			textCellEditor.getControl()
				.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
		}
		
		@Override
		public void applyEditorValue(){
			textCellEditor.getControl()
				.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
		}
	});
	
	focusCell =
		new TreeViewerFocusCellManager((TreeViewer) viewer, new FocusCellHighlighter(viewer) {
		
		});
		
	ColumnViewerEditorActivationStrategy actSupport =
		new ColumnViewerEditorActivationStrategy(viewer) {
			@Override
			protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event){
				return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
					|| event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
					|| (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED
						&& event.keyCode == SWT.CR)
					|| (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED
						&& event.keyCode == SWT.KEYPAD_CR)
					|| event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
			}
		};
	
	TreeViewerEditor.create((TreeViewer) viewer, focusCell, actSupport,
		ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION);
}
 
Example 12
Source File: PyUnitView.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void keyReleased(KeyEvent e) {
    if (e.widget == tree && (e.keyCode == SWT.LF || e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR)) {
        onTriggerGoToTest();
    }
}
 
Example 13
Source File: LineSeriesMarkerSheet.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
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 14
Source File: MarkerEditorComposite.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private void canvasEvent( Event event )
{
	switch ( event.type )
	{
		case SWT.FocusIn :
		{
			cnvMarker.redraw( );
			break;
		}
		case SWT.FocusOut :
		{
			cnvMarker.redraw( );
			break;
		}
		case SWT.KeyDown :
		{
			// At this point the widget may have been disposed.
			// If so, do not continue.
			if ( isDisposed( ) )
				break;

			if ( event.keyCode == SWT.ARROW_DOWN
					|| event.keyCode == SWT.CR
					|| event.keyCode == SWT.KEYPAD_CR )
			{
				event.doit = true;
				toggleDropDown( );
			}
			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;
					cnvMarker.redraw( );
			}

			break;
		}
		case SWT.Paint :
			paintMarker( event.gc, getMarker( ), LocationImpl.create( 10,
					10 ) );
			break;
	}
}
 
Example 15
Source File: BlockSelector.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public ViewerConfigurer createViewerConfigurer(CommonViewer cv){
	this.cv = cv;
	cv.setSelectionChangedListener(selChangeListener);
	makeActions();
	mgr = new MenuManager();
	mgr.setRemoveAllWhenShown(true);
	mgr.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
	mgr.addMenuListener(new IMenuListener() {
		
		public void menuAboutToShow(IMenuManager manager){
			Object selected = cv.getSelection()[0];
			if (selected instanceof BlockTreeViewerItem) {
				manager.add(tvfa);
				manager.add(deleteAction);
				manager.add(copyAction);
			}
			addPopupCommandContributions(manager, cv.getSelection());
		}
	});

	cv.setContextMenu(mgr);
	
	FieldDescriptor<?>[] lbName = new FieldDescriptor<?>[] {
		new FieldDescriptor<ICodeElementBlock>("Name")
	};
	
	// add keyListener to search field
	Listener keyListener = new Listener() {
		@Override
		public void handleEvent(Event event){
			if (event.type == eventType) {
				if (event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR) {
					slp.fireChangedEvent();
				}
			}
		}
	};
	for (FieldDescriptor<?> lbn : lbName) {
		lbn.setAssignedListener(eventType, keyListener);
	}
	
	slp = new SelectorPanelProvider(lbName, true);
	slp.addActions(createAction, exportAction, searchBlocksOnly, searchFilterMandator);
	ViewerConfigurer vc =
		new ViewerConfigurer(new BlockContentProvider(this, cv),
			new BlockTreeViewerItem.ColorizedLabelProvider(), slp,
			new ViewerConfigurer.DefaultButtonProvider(), new SimpleWidgetProvider(
				SimpleWidgetProvider.TYPE_TREE, SWT.NONE, null));
	vc.addDragSourceSelectionRenderer(new GenericObjectDragSource.ISelectionRenderer() {
		
		@Override
		public List<Object> getSelection(){
			IStructuredSelection selection = cv.getViewerWidget().getStructuredSelection();
			if (!selection.isEmpty()) {
				return collectSelections(selection);
			}
			return Collections.emptyList();
		}
	});
	return vc.setContentType(ContentType.GENERICOBJECT);
}
 
Example 16
Source File: FillChooserComposite.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
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( );
	}
}
 
Example 17
Source File: FillChooserComposite.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public void handleEvent( Event event )
{
	switch ( event.type )
	{
		case SWT.FocusOut :
			if ( event.widget instanceof ColorSelectionCanvas )
			{
				( (ColorSelectionCanvas) event.widget ).redraw( );
			}
			if ( isPopupControl( event.widget ) )
			{
				Control cTmp = isPressingKey ? getDisplay( ).getFocusControl( )
						: getDisplay( ).getCursorControl( );
				// Set default value back
				isPressingKey = false;
				if ( cTmp != null )
				{
					// Condition added to handle behavior under Linux
					if ( isPopupControl( cTmp )
							|| SWT.getPlatform( ).indexOf( "win32" ) == 0//$NON-NLS-1$
							&& ( cTmp.equals( cnvSelection ) || cTmp.equals( btnDown ) ) )
					{
						return;
					}

					if ( cTmp.equals( cnvSelection )
							|| cTmp.equals( btnDown ) )
					{
						bJustFocusLost = true;
					}
				}

				cmpDropDown.getShell( ).close( );
			}
			break;

		case SWT.KeyDown :
			if ( cmpDropDown != null
					&& !cmpDropDown.getShell( ).isDisposed( ) )
			{
				if ( event.keyCode == SWT.ARROW_UP )
				{
					cmpDropDown.getShell( ).close( );
				}
				else if ( event.keyCode == SWT.CR
						|| event.keyCode == SWT.KEYPAD_CR )
				{
					if ( srTransparency != null )
					{
						this.iTransparency = srTransparency.getSelection( );
					}
					if ( fCurrent instanceof ColorDefinition
							&& bTransparencyChanged )
					{
						( (ColorDefinition) fCurrent ).setTransparency( this.iTransparency );
					}
					this.setFill( fCurrent );
					cmpDropDown.getShell( ).close( );
				}
			}
			break;

		case SWT.Traverse :
			switch ( event.detail )
			{
				case SWT.TRAVERSE_TAB_NEXT :
				case SWT.TRAVERSE_TAB_PREVIOUS :
					// Indicates getting focus control rather than cursor
					// control
					isPressingKey = true;
					event.doit = true;
			}
			break;
	}

}
 
Example 18
Source File: FillChooserComposite.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
void handleEventCanvas( Event event )
{
	switch ( event.type )
	{
		case SWT.FocusIn :
		{
			cnvSelection.redraw( );
			break;
		}
		case SWT.FocusOut :
		{
			cnvSelection.redraw( );
			break;
		}
		case SWT.KeyDown :
		{
			if ( event.keyCode == SWT.KEYPAD_CR
					|| event.keyCode == SWT.CR
					|| event.keyCode == ' ' )
			{
				event.doit = true;
				toggleDropDown( );
			}
			break;
		}
		case SWT.MouseDown :
			if ( !bEnabled )
			{
				return;
			}
			// fireHandleEvent( MOUSE_CLICKED_EVENT );
			toggleDropDown( );
			break;
		case SWT.Traverse :
		{
			switch ( event.detail )
			{
				case SWT.TRAVERSE_ESCAPE :
					getShell( ).close( );
					break;
				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;
					cnvSelection.redraw( );
			}
			break;
		}
	}
}
 
Example 19
Source File: CDateTime.java    From nebula with 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 20
Source File: CalculatorButtonsComposite.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * 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);

}