Java Code Examples for org.eclipse.swt.SWT#KeyDown
The following examples show how to use
org.eclipse.swt.SWT#KeyDown .
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: PatternImageEditorDialog.java From birt with Eclipse Public License 1.0 | 6 votes |
@Override public void handleEvent( Event event ) { switch ( event.type ) { case SWT.MouseDown : int iRow = ( event.y - MARGIN ) / CELL_WIDTH; int iCol = ( event.x - MARGIN ) / CELL_HEIGHT; select( iRow, iCol ); break; case SWT.KeyDown : processKeyDown( event.keyCode ); break; } super.handleEvent( event ); }
Example 2
Source File: FillChooserComposite.java From birt with Eclipse Public License 1.0 | 6 votes |
public void handleEvent( Event event ) { switch ( event.type ) { case SWT.Paint : paintControl( new PaintEvent( event ) ); break; case SWT.FocusIn : redraw( ); break; case SWT.KeyDown : keyDown( event ); break; case SWT.MouseDown : if ( !bEnabled ) { return; } fireHandleEvent( MOUSE_CLICKED_EVENT ); setColorToModel( this.getColorAt( event.x, event.y ) ); cmpDropDown.getShell( ).close( ); break; } }
Example 3
Source File: CCombo.java From birt with Eclipse Public License 1.0 | 6 votes |
void createPopup(String[] items, int selectionIndex) { // create shell and list popup = new Shell (getShell(), SWT.NO_TRIM | SWT.ON_TOP); int style = getStyle(); int listStyle = SWT.SINGLE | SWT.V_SCROLL; if ((style & SWT.FLAT) != 0) listStyle |= SWT.FLAT; if ((style & SWT.RIGHT_TO_LEFT) != 0) listStyle |= SWT.RIGHT_TO_LEFT; if ((style & SWT.LEFT_TO_RIGHT) != 0) listStyle |= SWT.LEFT_TO_RIGHT; list = new List (popup, listStyle); if (font != null) list.setFont(font); if (foreground != null) list.setForeground(foreground); if (background != null) list.setBackground(background); int [] popupEvents = {SWT.Close, SWT.Paint, SWT.Deactivate}; for (int i=0; i<popupEvents.length; i++) popup.addListener (popupEvents [i], listener); int [] listEvents = {SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.FocusOut, SWT.Dispose}; for (int i=0; i<listEvents.length; i++) list.addListener (listEvents [i], listener); if (items != null) list.setItems(items); if (selectionIndex != -1) list.setSelection(selectionIndex); }
Example 4
Source File: DirtyStateEditorSupportIntegrationTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected void pushKey(char c, int k) throws Exception { String textBefore = editor.getDocument().get(); Event event = new Event(); event.type = SWT.KeyDown; event.character = c; event.keyCode = k; myDisplay.post(event); syncUtil.yieldToQueuedDisplayJobs(new NullProgressMonitor()); Event event2 = new Event(); event2.type = SWT.KeyUp; event2.character = c; event2.keyCode = k; myDisplay.post(event2); int maxTries = 10; while (maxTries-- > 0) { if (!Objects.equal(editor.getDocument().get(), textBefore)) { syncUtil.waitForReconciler(editor); return; } Thread.sleep(10); syncUtil.yieldToQueuedDisplayJobs(new NullProgressMonitor()); } Assert.fail("Document didn't change on keystroke"); }
Example 5
Source File: CustomChooserComposite.java From birt with Eclipse Public License 1.0 | 5 votes |
void handleEventCmpDropDown( Event event ) { switch ( event.type ) { case SWT.KeyDown : { keyPressed( new KeyEvent( event ) ); break; } case SWT.FocusOut : { Control cTmp = Display.getCurrent( ).getCursorControl( ); if ( cTmp != null ) { if ( cTmp.equals( cnvSelection ) || cTmp.equals( btnDown ) ) { bJustFocusLost = true; } } if ( !isPopupControl( cTmp ) ) { cmpDropDown.getShell( ).close( ); } break; } } }
Example 6
Source File: Bug493784Test.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
private void pressKey(final XtextEditor editor, final char c) throws Exception { final StyledText textWidget = editor.getInternalSourceViewer().getTextWidget(); final Event e = new Event(); e.character = c; e.type = SWT.KeyDown; e.doit = true; textWidget.notifyListeners(SWT.KeyDown, e); }
Example 7
Source File: TableCombo.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * creates the popup shell. * @param selectionIndex */ void createPopup(int selectionIndex) { // create shell and table popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP); // create table table = new Table(popup, SWT.SINGLE | SWT.FULL_SELECTION); if (font != null) table.setFont(font); if (foreground != null) table.setForeground(foreground); if (background != null) table.setBackground(background); // Add popup listeners int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate }; for (int i = 0; i < popupEvents.length; i++) { popup.addListener(popupEvents[i], listener); } // add table listeners int[] tableEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose }; for (int i = 0; i < tableEvents.length; i++) { table.addListener(tableEvents[i], listener); } // set the selection if (selectionIndex != -1) { table.setSelection(selectionIndex); } }
Example 8
Source File: AbstractAutoEditTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
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 9
Source File: KbdMacroSupport.java From e4macs with Eclipse Public License 1.0 | 5 votes |
private Event matchEvent(char c, int keyCode, int mask) { Event e = new Event(); e.keyCode = keyCode; e.character = c; e.stateMask = mask; e.type = SWT.KeyDown; e.doit = true; return e; }
Example 10
Source File: AbstractAutoEditTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
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 11
Source File: SelfRelationCreationTool.java From ermasterr with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected boolean handleButtonDown(final int button) { if (button == SWT.KeyDown) { return handleCreateConnection(); } return super.handleButtonDown(button); }
Example 12
Source File: BonitaRulerGridPropertySection.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event) */ public void handleEvent(Event event) { switch (event.type) { case SWT.KeyDown: textModified = true; if (event.character == SWT.CR) textChanged((Control) event.widget); break; case SWT.FocusOut: textChanged((Control) event.widget); break; } }
Example 13
Source File: KbdMacroSupport.java From e4macs with Eclipse Public License 1.0 | 5 votes |
private Event copyEvent(VerifyEvent event) { Event e = new Event(); e.stateMask = event.stateMask; e.keyCode = event.keyCode; // display.post() wants the key character sans modifier e.character = (event.keyCode != 0 ? (char)event.keyCode : event.character); // e.character = event.character; e.type = SWT.KeyDown; e.doit = true; return e; }
Example 14
Source File: VControl.java From nebula with Eclipse Public License 2.0 | 5 votes |
private boolean include(boolean key, int type) { if(type == SWT.Selection) { return false; } if(key && (type == SWT.KeyDown || type == SWT.KeyUp || type == SWT.Traverse)) { return true; } if(!key && !(type == SWT.KeyDown || type == SWT.KeyUp || type == SWT.Traverse)) { return true; } return false; }
Example 15
Source File: BaseCombo.java From nebula with Eclipse Public License 2.0 | 5 votes |
private void createText(int style) { textListener = new Listener() { public void handleEvent(Event event) { switch (event.type) { case SWT.KeyDown: if (event.stateMask == SWT.CTRL && event.keyCode == ' ') { event.doit = false; setOpen(true); } break; case SWT.Modify: Event e = new Event(); e.time = event.time; setModifyEventProperties(e); notifyListeners(SWT.Modify, e); break; } } }; int mask = SWT.TRAIL | SWT.LEAD; int textStyle = SWT.SINGLE | (style & mask); if (!win32 && (style & SWT.BORDER) != 0) { textStyle |= SWT.BORDER; } text = VNative.create(Text.class, panel, textStyle); addTextListener(); }
Example 16
Source File: InformationPresenterControlManager.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@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 17
Source File: RunEditorAsCustomUnitTestAction.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@Override public void handleEvent(Event event) { if (event.keyCode == SWT.SHIFT) { if (event.type == SWT.KeyDown) { shiftPressed = true; onChanged.call(shiftPressed); } else if (event.type == SWT.KeyUp) { shiftPressed = false; onChanged.call(shiftPressed); } } }
Example 18
Source File: MarkerEditorComposite.java From birt with Eclipse Public License 1.0 | 4 votes |
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
Source File: FillChooserComposite.java From birt with Eclipse Public License 1.0 | 4 votes |
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 20
Source File: BidiLayout.java From nebula with Eclipse Public License 2.0 | 4 votes |
private void addListeners() { listener = new Listener() { @Override public void handleEvent(Event event) { switch (event.type) { case SWT.MouseDown: handleMouseDown(event); break; case SWT.KeyDown: handleKeyDown(event); break; } } }; addAndReorderListener(SWT.KeyDown, listener); styledText.addListener(SWT.MouseDown, listener); addAndReorderListener(SWT.Show, listener); styledText.addKeyListener(new KeyListener() { @Override public void keyReleased(KeyEvent keyEvent) { if ((keyEvent.keyCode == 'u') && ((keyEvent.stateMask & SWT.CTRL) != 0)){ setPush(true); keyEvent.doit = false; }else if ((keyEvent.keyCode == 'o') && ((keyEvent.stateMask & SWT.CTRL) != 0)) { setPush(false); keyEvent.doit = false; } else if ((keyEvent.keyCode == 't') && ((keyEvent.stateMask & SWT.CTRL) != 0)){ switchAutoPush(); keyEvent.doit = false; } else if (isPushMode && (keyEvent.keyCode == SWT.HOME || keyEvent.keyCode==SWT.END)){ int carPos = getCaretOffset(); setPush(false); setCaretOffset(carPos); } } @Override public void keyPressed(KeyEvent e) { } }); }