Java Code Examples for org.eclipse.swt.SWT#HOME
The following examples show how to use
org.eclipse.swt.SWT#HOME .
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: SearchMinibuffer.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * @see com.mulgasoft.emacsplus.minibuffer.WithMinibuffer#noCharEvent(org.eclipse.swt.events.VerifyEvent) */ protected void noCharEvent(VerifyEvent event) { switch (event.keyCode) { // remove minimal support for in line editing case SWT.HOME: case SWT.END: case SWT.ARROW_LEFT: case SWT.ARROW_RIGHT: case SWT.PAGE_DOWN: case SWT.PAGE_UP: // Since we've disabled the key filter force the action by // disabling the key, and calling the command directly // since Mac doesn't handle simple resendEvent well event.doit = false; ITextEditor ed= this.getEditor(); leave(); executeBinding(ed, event.stateMask, event); break; default: super.noCharEvent(event); break; } }
Example 2
Source File: DatePicker.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * perform the scroll by making a call to {@link #adjustDays(int, int)} with * the <code>field</code> set to Calendar.DATE and the <code>amount</code> * corresponding to the keycode. */ private void scrollCalendar(int keycode) { if (scrollable) { switch (keycode) { case SWT.ARROW_DOWN: adjustDays(Calendar.DATE, 7); break; case SWT.ARROW_UP: adjustDays(Calendar.DATE, -7); break; case SWT.END: adjustDays(Calendar.YEAR, 1); break; case SWT.HOME: adjustDays(Calendar.YEAR, -1); break; case SWT.PAGE_DOWN: adjustDays(Calendar.MONTH, 1); break; case SWT.PAGE_UP: adjustDays(Calendar.MONTH, -1); break; } } }
Example 3
Source File: InternalCompositeTable.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * Handle a keyPressed event on any row control. * * @param sender * The row that is sending the event * @param e * the actual KeyEvent */ public void keyPressed(TableRow sender, KeyEvent e) { if (doMakeFocusedRowVisible()) return; if ((e.stateMask & SWT.CONTROL) != 0) { switch (e.keyCode) { case SWT.HOME: doFocusInitialRow(); return; case SWT.END: doFocusLastRow(); return; case SWT.INSERT: doInsertRow(); return; case SWT.DEL: doDeleteRow(); return; default: return; } } switch (e.keyCode) { case SWT.ARROW_UP: doRowUp(); return; case SWT.ARROW_DOWN: doRowDown(); return; case SWT.PAGE_UP: doPageUp(); return; case SWT.PAGE_DOWN: doPageDown(); return; } }
Example 4
Source File: DocumentManager.java From ContentAssist with MIT License | 5 votes |
/** * Tests if a given key event may move the current cursor position. * @param event the key event * @return <code>true</code> if the key event may move the current cursor position, otherwise <code>false</code> */ private boolean cursorMoved(Event event) { final int key = (SWT.KEY_MASK & event.keyCode); switch (key) { case SWT.ARROW_DOWN: case SWT.ARROW_LEFT: case SWT.ARROW_RIGHT: case SWT.ARROW_UP: case SWT.HOME: case SWT.END: case SWT.PAGE_DOWN: return true; } return false; }
Example 5
Source File: HopGuiPipelineGraph.java From hop with Apache License 2.0 | 5 votes |
@GuiToolbarElement( root = GUI_PLUGIN_TOOLBAR_PARENT_ID, id = TOOLBAR_ITEM_SNAP_TO_GRID, // label = "Snap to grid", toolTip = "Align the selected transforms to the specified grid size", image = "ui/images/toolbar/snap-to-grid.svg", disabledImage = "ui/images/toolbar/snap-to-grid-disabled.svg" ) @GuiKeyboardShortcut( control = true, key = SWT.HOME ) @GuiOsxKeyboardShortcut( command = true, key = SWT.HOME ) public void snapToGrid() { snapToGrid( ConstUi.GRID_SIZE ); }
Example 6
Source File: TypingRunDetector.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void keyPressed(KeyEvent e) { switch (e.keyCode) { case SWT.ARROW_UP: case SWT.ARROW_DOWN: case SWT.ARROW_LEFT: case SWT.ARROW_RIGHT: case SWT.END: case SWT.HOME: case SWT.PAGE_DOWN: case SWT.PAGE_UP: handleSelectionChanged(); break; } }
Example 7
Source File: PatternImageEditorDialog.java From birt with Eclipse Public License 1.0 | 5 votes |
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 File: PatternImageEditorDialog.java From birt with Eclipse Public License 1.0 | 5 votes |
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 9
Source File: ContextInformationPopup.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
/** * 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 10
Source File: JobGraph.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public void keyPressed( KeyEvent e ) { // Delete if ( e.keyCode == SWT.DEL ) { List<JobEntryCopy> copies = jobMeta.getSelectedEntries(); if ( copies != null && copies.size() > 0 ) { delSelected(); } } if ( e.keyCode == SWT.F1 ) { spoon.browseVersionHistory(); } // CTRL-UP : allignTop(); if ( e.keyCode == SWT.ARROW_UP && ( e.stateMask & SWT.MOD1 ) != 0 ) { alligntop(); } // CTRL-DOWN : allignBottom(); if ( e.keyCode == SWT.ARROW_DOWN && ( e.stateMask & SWT.MOD1 ) != 0 ) { allignbottom(); } // CTRL-LEFT : allignleft(); if ( e.keyCode == SWT.ARROW_LEFT && ( e.stateMask & SWT.MOD1 ) != 0 ) { allignleft(); } // CTRL-RIGHT : allignRight(); if ( e.keyCode == SWT.ARROW_RIGHT && ( e.stateMask & SWT.MOD1 ) != 0 ) { allignright(); } // ALT-RIGHT : distributeHorizontal(); if ( e.keyCode == SWT.ARROW_RIGHT && ( e.stateMask & SWT.ALT ) != 0 ) { distributehorizontal(); } // ALT-UP : distributeVertical(); if ( e.keyCode == SWT.ARROW_UP && ( e.stateMask & SWT.ALT ) != 0 ) { distributevertical(); } // ALT-HOME : snap to grid if ( e.keyCode == SWT.HOME && ( e.stateMask & SWT.ALT ) != 0 ) { snaptogrid( ConstUI.GRID_SIZE ); } // CTRL-W or CTRL-F4 : close tab if ( ( e.keyCode == 'w' && ( e.stateMask & SWT.MOD1 ) != 0 ) || ( e.keyCode == SWT.F4 && ( e.stateMask & SWT.MOD1 ) != 0 ) ) { spoon.tabCloseSelected(); } }
Example 11
Source File: OfflineActionTarget.java From Pydev with Eclipse Public License 1.0 | 4 votes |
@Override public void verifyKey(VerifyEvent event) { if (!event.doit) return; if (event.character == 0) { switch (event.keyCode) { case SWT.ARROW_DOWN: //special case: //if there's a key dialog with a table shown, set its focus when down is pressed synchronized (lock) { KeyAssistDialog tempKeyAssistDialog = this.keyAssistDialog; if (tempKeyAssistDialog != null) { Table completionsTable = this.keyAssistDialog.getCompletionsTable(); if (completionsTable != null && !completionsTable.isDisposed()) { completionsTable.setFocus(); completionsTable.setSelection(0); event.doit = false; break; } } } // ALT, CTRL, ARROW_LEFT, ARROW_RIGHT == leave case SWT.ARROW_LEFT: case SWT.ARROW_RIGHT: case SWT.HOME: case SWT.END: case SWT.PAGE_DOWN: case SWT.PAGE_UP: case SWT.ARROW_UP: leave(); break; } // event.character != 0 } else { switch (event.character) { // ESC = quit case 0x1B: leave(); event.doit = false; break; //CR = exec and quit case 0x0D: boolean executed = doExec(); event.doit = false; if (!executed) { return; //we don't want to update the status } break; // backspace and delete case 0x08: case 0x7F: removeLastCharSearch(); event.doit = false; break; default: if (event.stateMask == 0 || event.stateMask == SWT.SHIFT || event.stateMask == (SWT.ALT | SWT.CTRL)) { // SWT.ALT | SWT.CTRL covers AltGr (see bug 43049) event.doit = false; if (addCharSearch(event.character)) { //ok, triggered some automatic action (does not need enter) executed = doExec(); if (!executed) { return; //we don't want to update the status } } } break; } } updateStatus(); }
Example 12
Source File: FirstCharAction.java From Pydev with Eclipse Public License 1.0 | 4 votes |
/** * Creates a handler that will properly treat home considering python code (if it's still not defined * by the platform -- otherwise, just go with what the platform provides). */ public static VerifyKeyListener createVerifyKeyListener(final SourceViewer viewer, final IWorkbenchPartSite site, boolean forceCreation) { // This only needs to be done for eclipse 3.2 (where line start is not // defined). // Eclipse 3.3 onwards already defines the home key in the text editor. final boolean isDefined; if (site != null) { ICommandService commandService = (ICommandService) site.getService(ICommandService.class); Collection definedCommandIds = commandService.getDefinedCommandIds(); isDefined = definedCommandIds.contains("org.eclipse.ui.edit.text.goto.lineStart"); } else { isDefined = false; } if (forceCreation || !isDefined) { return new VerifyKeyListener() { @Override public void verifyKey(VerifyEvent event) { if (event.doit) { boolean isHome; if (isDefined) { isHome = KeyBindingHelper.matchesKeybinding(event.keyCode, event.stateMask, "org.eclipse.ui.edit.text.goto.lineStart"); } else { isHome = event.keyCode == SWT.HOME && event.stateMask == 0; } if (isHome) { ISelection selection = viewer.getSelection(); if (selection instanceof ITextSelection) { FirstCharAction firstCharAction = new FirstCharAction(); firstCharAction.viewer = viewer; firstCharAction.perform(viewer.getDocument(), (ITextSelection) selection); event.doit = false; } } } } }; } return null; }
Example 13
Source File: WithMinibuffer.java From e4macs with Eclipse Public License 1.0 | 4 votes |
protected void noCharEvent(VerifyEvent event) { switch (event.keyCode) { case SWT.CTRL: if (handlesCtrl()) { break; } closeDialog(); // else close dialog and leave leave(); break; case SWT.ALT: if (handlesAlt()) { break; } closeDialog(); // else close dialog and leave leave(); break; case SWT.PAGE_DOWN: // leave case SWT.PAGE_UP: case SWT.ARROW_DOWN: case SWT.ARROW_UP: leave(); break; // minimal support for in line editing case SWT.HOME: getMB().toBegin(); event.doit = false; break; case SWT.END: getMB().toEnd(); event.doit = false; break; case SWT.ARROW_LEFT: getMB().toLeft(); event.doit = false; break; case SWT.ARROW_RIGHT: getMB().toRight(); event.doit = false; break; } }
Example 14
Source File: TableCellKeyDelegate.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * @see org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler#keyPressed(org.eclipse.swt.events.KeyEvent) */ public boolean keyPressed( KeyEvent event ) { if ( event.character == ' ' ) { processSelect( event ); return true; } else if ( acceptIntoContainer( event ) ) { navigateIntoContainer( event ); return true; } else if ( acceptOutOf( event ) ) { navigateOut( event ); return true; } else if ( acceptConnection( event ) ) { navigateConnections( event ); return true; } else if ( acceptScroll( event ) ) { scrollViewer( event ); return true; } else if ( acceptLeaveConnection( event ) ) { navigateOutOfConnection( event ); return true; } else if ( acceptLeaveContents( event ) ) { navigateIntoContainer( event ); return true; } switch ( event.keyCode ) { case SWT.ARROW_LEFT : if ( navigateNextSibling( event, PositionConstants.WEST ) ) return true; break; case SWT.ARROW_RIGHT : if ( navigateNextSibling( event, PositionConstants.EAST ) ) return true; break; case SWT.ARROW_UP : if ( navigateNextSibling( event, PositionConstants.NORTH ) ) return true; break; case SWT.ARROW_DOWN : if ( navigateNextSibling( event, PositionConstants.SOUTH ) ) return true; break; case SWT.HOME : if ( navigateJumpSibling( event, PositionConstants.WEST ) ) return true; break; case SWT.END : if ( navigateJumpSibling( event, PositionConstants.EAST ) ) return true; break; case SWT.PAGE_DOWN : if ( navigateJumpSibling( event, PositionConstants.SOUTH ) ) return true; break; case SWT.PAGE_UP : if ( navigateJumpSibling( event, PositionConstants.NORTH ) ) return true; } return super.keyPressed( event ); }
Example 15
Source File: GLScene.java From depan with Apache License 2.0 | 4 votes |
/** * A key stroke was received by the OpenGL canvas but it wasn't used by the * previous layers. Give someone else a chance to use it. * * This is intended to be overridden, and {@code super.uncaughtKey()} * should be the final statement of such methods. Normally, this is the * "last gasp" key handler. */ public void uncaughtKey(KeyEvent event, boolean keyCtrlState, boolean keyAltState, boolean keyShiftState) { switch (event.keyCode) { case SWT.ARROW_UP: if ((event.stateMask & SWT.CTRL) != 0) { rotateCamera(-0.5f, 0.0f, 0.0f); } else { pedestalCamera(-5.0f); } break; case SWT.ARROW_DOWN: if ((event.stateMask & SWT.CTRL) != 0) { rotateCamera(0.5f, 0.0f, 0.0f); } else { pedestalCamera(5.0f); } break; case SWT.ARROW_LEFT: if ((event.stateMask & SWT.CTRL) != 0) { rotateCamera(0.0f, 0.0f, -0.5f); } else { truckCamera(-5.0f); } break; case SWT.ARROW_RIGHT: if ((event.stateMask & SWT.CTRL) != 0) { rotateCamera(0.0f, 0.0f, 0.5f); } else { truckCamera(5.0f); } break; case SWT.PAGE_UP: zoomCamera(5.0f); break; case SWT.PAGE_DOWN: zoomCamera(-5.0f); break; case SWT.HOME: homeCamera(); break; default: logUncaughtKey(event.keyCode, event.character, keyCtrlState, keyAltState, keyShiftState); } }
Example 16
Source File: Histogram.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * Move the currently selected bar cursor. * * @param keyCode * the SWT key code */ protected void moveCursor(final int keyCode) { int index; switch (keyCode) { case SWT.HOME: fScaledData.fSelectionBeginBucket = 0; break; case SWT.END: fScaledData.fSelectionBeginBucket = fScaledData.fWidth - 1; break; case SWT.ARROW_RIGHT: { long prevStartTime = getTimestamp(fScaledData.fSelectionBeginBucket); index = Math.max(0, Math.min(fScaledData.fWidth - 1, fScaledData.fSelectionBeginBucket + 1)); while (index < fScaledData.fWidth && (fScaledData.fData[index].isEmpty() || prevStartTime == getTimestamp(index))) { prevStartTime = getTimestamp(index); index++; } if (index >= fScaledData.fWidth) { index = fScaledData.fWidth - 1; } fScaledData.fSelectionBeginBucket = index; break; } case SWT.ARROW_LEFT: { long prevEndTime = getTimestamp(fScaledData.fSelectionBeginBucket + 1); index = Math.max(0, Math.min(fScaledData.fWidth - 1, fScaledData.fSelectionBeginBucket - 1)); while (index >= 0 && (fScaledData.fData[index].isEmpty() || prevEndTime == getTimestamp(index + 1))) { prevEndTime = getTimestamp(index + 1); index--; } if (index <= 0) { index = 0; } fScaledData.fSelectionBeginBucket = index; break; } default: return; } fScaledData.fSelectionEndBucket = fScaledData.fSelectionBeginBucket; fSelectionBegin = getTimestamp(fScaledData.fSelectionBeginBucket); fSelectionEnd = fSelectionBegin; updateSelectionTime(); }
Example 17
Source File: Launcher.java From nebula with Eclipse Public License 2.0 | 4 votes |
/** * Code executed when a key is pressed * * @param event Event */ private void handleKeyPressedEvent(final Event event) { switch (event.keyCode) { case SWT.ARROW_LEFT: if (selection == -1) { selection = 0; changeColor(selection, true); return; } if (selection % 2 != 0) { changeColor(selection, false); selection--; changeColor(selection, true); } break; case SWT.ARROW_UP: if (selection == -1) { selection = 0; changeColor(selection, true); return; } if (selection >= 2) { changeColor(selection, false); selection -= 2; changeColor(selection, true); } break; case SWT.ARROW_RIGHT: if (selection == -1) { selection = 0; changeColor(selection, true); return; } if (selection % 2 == 0) { changeColor(selection, false); selection++; changeColor(selection, true); } break; case SWT.ARROW_DOWN: if (selection == -1) { selection = 0; changeColor(selection, true); return; } if (selection <= items.size() - 2) { changeColor(selection, false); selection += 2; changeColor(selection, true); } break; case SWT.HOME: changeColor(selection, false); selection = 0; changeColor(selection, true); break; case SWT.END: changeColor(selection, false); selection = items.size() - 1; changeColor(selection, true); break; } }
Example 18
Source File: DateChooser.java From nebula with Eclipse Public License 2.0 | 4 votes |
/** * Manages event at the calendar level. * * @param event event */ protected void calendarEvent(Event event) { switch (event.type) { case SWT.Traverse: switch (event.detail) { case SWT.TRAVERSE_ARROW_NEXT: case SWT.TRAVERSE_ARROW_PREVIOUS: case SWT.TRAVERSE_PAGE_NEXT: case SWT.TRAVERSE_PAGE_PREVIOUS: event.doit = false; break; default: event.doit = true; } break; case SWT.FocusIn: handleFocus(event.type); break; case SWT.KeyDown: { final boolean ctrl = (event.stateMask & SWT.CTRL) != 0; switch (event.keyCode) { case SWT.ARROW_LEFT: if (event.stateMask != 0) { return; } setFocus(focusIndex - 1); break; case SWT.ARROW_RIGHT: if (event.stateMask != 0) { return; } setFocus(focusIndex + 1); break; case SWT.ARROW_UP: if (event.stateMask != 0) { return; } setFocus(focusIndex - 7); break; case SWT.ARROW_DOWN: if (event.stateMask != 0) { return; } setFocus(focusIndex + 7); break; case SWT.PAGE_DOWN: if (event.stateMask != 0 || !navigationEnabled) { return; } changeCurrentMonth(ctrl ? 12 : 1); break; case SWT.PAGE_UP: if (event.stateMask != 0 || !navigationEnabled) { return; } changeCurrentMonth(ctrl ? -12 : -1); break; case ' ': select(focusIndex, event.stateMask); break; case SWT.HOME: if (event.stateMask != 0) { return; } setFocusOnToday(autoSelectOnFooter); break; default: return; } if (hasFocus) { gridRedraw(); } break; } case SWT.Dispose: { final Display display = getDisplay(); display.removeFilter(SWT.FocusIn, filter); display.removeFilter(SWT.KeyDown, filter); hasFocus = false; break; } } }
Example 19
Source File: GuiMenuWidgets.java From hop with Apache License 2.0 | 4 votes |
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 20
Source File: ContextDialog.java From hop with Apache License 2.0 | 4 votes |
private void onKeyPressed( KeyEvent event ) { if ( filteredItems.isEmpty() ) { return; } Rectangle area = wCanvas.getClientArea(); int pageRows = Math.floorDiv( area.height, cellHeight ); int nrColumns = calculateNrColumns(); int nrRows = calculateNrRows(); int index = filteredItems.indexOf( selectedItem ); switch ( event.keyCode ) { case SWT.ARROW_DOWN: if ( index + nrColumns < filteredItems.size() ) { index += nrColumns; } break; case SWT.ARROW_UP: if ( index - nrColumns >= 0 ) { index -= nrColumns; } break; case SWT.PAGE_UP: if ( index - ( pageRows * nrColumns ) > 0 ) { index -= pageRows * nrColumns; } else { index = Math.floorMod( index, nrColumns ); } break; case SWT.PAGE_DOWN: if ( index + ( pageRows * nrColumns ) < filteredItems.size() - 1 ) { index += pageRows * nrColumns; } else { index = ( nrRows - 1 ) * nrColumns + Math.floorMod( index, nrColumns ); if ( index > filteredItems.size() - 1 ) { index = ( nrRows - 2 ) * nrColumns + Math.floorMod( index, nrColumns ); } } break; case SWT.ARROW_LEFT: if ( index > 0 ) { index--; } break; case SWT.ARROW_RIGHT: if ( index < filteredItems.size() - 1 ) { index++; } break; case SWT.HOME: // Position on the first row and column of the screen index = 0; break; case SWT.END: // Position on the last row and column of the screen index = filteredItems.size() - 1; break; } if (index>=0 && index<filteredItems.size()) { selectItem( filteredItems.get( index ) ); } }