org.eclipse.swt.events.TraverseEvent Java Examples
The following examples show how to use
org.eclipse.swt.events.TraverseEvent.
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: ComponentStatusLabel.java From arx with Apache License 2.0 | 6 votes |
/** * On mnemonic handler * * @param event */ void onMnemonic(TraverseEvent event) { char mnemonic = _findMnemonic(text); if (mnemonic == '\0') return; if (Character.toLowerCase(event.character) != mnemonic) return; Composite control = this.getParent(); while (control != null) { Control[] children = control.getChildren(); int index = 0; while (index < children.length) { if (children[index] == this) break; index++; } index++; if (index < children.length) { if (children[index].setFocus()) { event.doit = true; event.detail = SWT.TRAVERSE_NONE; } } control = control.getParent(); } }
Example #2
Source File: HistoryMinibuffer.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * Disable eclipse traversal event, and dispatch into our Alt/Ctrl * handlers in place of it * * @param e the trapped TraverseEvent */ protected void handleTraverseEvent(TraverseEvent e) { // setting detail to NONE but doit=true disables further processing e.detail = SWT.TRAVERSE_NONE; e.doit = true; Event ee = new Event(); ee.character = e.character; ee.doit = true; ee.stateMask = (e.stateMask & SWT.MODIFIER_MASK); ee.keyCode = e.keyCode; ee.display = e.display; ee.widget = e.widget; // will throw an exception if not valid ee.time = e.time; ee.data = e.data; switch (ee.stateMask) { case SWT.CONTROL: // Emacs+ key binding forces CTRL dispatchCtrl(new VerifyEvent(ee)); break; case SWT.ALT: // AFAIK MOD3 is always ALT dispatchAlt(new VerifyEvent(ee)); break; } }
Example #3
Source File: HistoryMinibuffer.java From e4macs with Eclipse Public License 1.0 | 6 votes |
public void keyTraversed(TraverseEvent e) { switch (e.detail) { case SWT.TRAVERSE_MNEMONIC: if ((e.stateMask & SWT.MOD3) != 0) { switch (e.character) { case PREV: case NEXT: // if no key binding (which would take precedence) // then pass to our handlers it directly if (!hasBinding(e)){ handleTraverseEvent(e); } } } break; default: } }
Example #4
Source File: ExpressionSyntaxColoringPage.java From birt with Eclipse Public License 1.0 | 6 votes |
private TraverseListener getTraverseListener( ) { return new TraverseListener( ) { /** * @see org.eclipse.swt.events.TraverseListener#keyTraversed(TraverseEvent) */ public void keyTraversed( TraverseEvent e ) { if ( e.widget instanceof StyledText ) { if ( ( e.detail == SWT.TRAVERSE_TAB_NEXT ) || ( e.detail == SWT.TRAVERSE_TAB_PREVIOUS ) ) e.doit = true; } } }; }
Example #5
Source File: TextBoxDialogField.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected Text createTextControl(Composite parent) { Text text= new Text(parent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); text.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent event) { switch (event.detail) { case SWT.TRAVERSE_ESCAPE: case SWT.TRAVERSE_PAGE_NEXT: case SWT.TRAVERSE_PAGE_PREVIOUS: event.doit= true; break; case SWT.TRAVERSE_RETURN: case SWT.TRAVERSE_TAB_NEXT: case SWT.TRAVERSE_TAB_PREVIOUS: if ((event.stateMask & SWT.MODIFIER_MASK) != 0) { event.doit= true; } break; } } }); return text; }
Example #6
Source File: TypeSelectionComponent.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private Control createHeader(Composite parent, Font font, String message) { Composite header= new Composite(parent, SWT.NONE); GridLayout layout= new GridLayout(); layout.numColumns= 2; layout.marginWidth= 0; layout.marginHeight= 0; header.setLayout(layout); header.setFont(font); Label label= new Label(header, SWT.NONE); label.setText(message); label.setFont(font); label.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { if (e.detail == SWT.TRAVERSE_MNEMONIC && e.doit) { e.detail= SWT.TRAVERSE_NONE; fFilter.setFocus(); } } }); GridData gd= new GridData(GridData.FILL_HORIZONTAL); label.setLayoutData(gd); createViewMenu(header); return header; }
Example #7
Source File: ListenerAppender.java From erflute with Apache License 2.0 | 5 votes |
public static void addTraverseListener(final Text textArea) { textArea.addTraverseListener(new TraverseListener() { @Override public void keyTraversed(TraverseEvent e) { if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) { e.doit = true; } } }); }
Example #8
Source File: ListenerAppender.java From ermaster-b with Apache License 2.0 | 5 votes |
public static void addTraverseListener(final Text textArea) { textArea.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) { e.doit = true; } } }); }
Example #9
Source File: DQSystemInfoPage.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private Text createTextCell(Composite composite, int heightFactor, int widthFactor) { Text text = toolkit.createText(composite, null, SWT.BORDER | SWT.MULTI | SWT.WRAP); text.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) { e.doit = true; } } }); setGridData(text, heightFactor, widthFactor); return text; }
Example #10
Source File: CompletionMinibuffer.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * Enable tab completion by disabling tab traversal * * @see com.mulgasoft.emacsplus.minibuffer.HistoryMinibuffer#keyTraversed(org.eclipse.swt.events.TraverseEvent) */ public void keyTraversed(TraverseEvent e) { switch (e.detail) { case SWT.TRAVERSE_TAB_NEXT: // ignore tab traversal e.doit = false; break; default: super.keyTraversed(e); } }
Example #11
Source File: AccordionLabel.java From birt with Eclipse Public License 1.0 | 5 votes |
void onMnemonic( TraverseEvent event ) { char mnemonic = _findMnemonic( text ); if ( mnemonic == '\0' ) return; if ( Character.toLowerCase( event.character ) != mnemonic ) return; Composite control = this.getParent( ); while ( control != null ) { Control[] children = control.getChildren( ); int index = 0; while ( index < children.length ) { if ( children[index] == this ) break; index++; } index++; if ( index < children.length ) { if ( children[index].setFocus( ) ) { event.doit = true; event.detail = SWT.TRAVERSE_NONE; } } control = control.getParent( ); } }
Example #12
Source File: CustomPreviewTable.java From birt with Eclipse Public License 1.0 | 5 votes |
public void keyTraversed( TraverseEvent e ) { if ( e.character != SWT.TAB ) { e.doit = false; } }
Example #13
Source File: SARLArgumentsTab.java From sarl with Apache License 2.0 | 5 votes |
private void createSREArgsText(Group group, Font font) { this.sreArgumentsText = new Text(group, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL); this.sreArgumentsText.addTraverseListener(new TraverseListener() { @Override public void keyTraversed(TraverseEvent event) { switch (event.detail) { case SWT.TRAVERSE_ESCAPE: case SWT.TRAVERSE_PAGE_NEXT: case SWT.TRAVERSE_PAGE_PREVIOUS: event.doit = true; break; case SWT.TRAVERSE_RETURN: case SWT.TRAVERSE_TAB_NEXT: case SWT.TRAVERSE_TAB_PREVIOUS: if ((SARLArgumentsTab.this.sreArgumentsText.getStyle() & SWT.SINGLE) != 0) { event.doit = true; } else { if (!SARLArgumentsTab.this.sreArgumentsText.isEnabled() || (event.stateMask & SWT.MODIFIER_MASK) != 0) { event.doit = true; } } break; default: } } }); final GridData gd = new GridData(GridData.FILL_BOTH); gd.heightHint = HEIGHT_HINT; gd.widthHint = WIDTH_HINT; this.sreArgumentsText.setLayoutData(gd); this.sreArgumentsText.setFont(font); this.sreArgumentsText.addModifyListener(new ModifyListener() { @SuppressWarnings("synthetic-access") @Override public void modifyText(ModifyEvent evt) { scheduleUpdateJob(); } }); ControlAccessibleListener.addListener(this.sreArgumentsText, group.getText()); }
Example #14
Source File: CommitCommentArea.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public void keyTraversed(TraverseEvent e) { if (e.detail == SWT.TRAVERSE_RETURN && (e.stateMask & SWT.SHIFT) != 0) { e.doit = false; return; } if (e.detail == SWT.TRAVERSE_RETURN && (e.stateMask & SWT.CTRL) != 0) { e.doit = false; firePropertyChangeChange(OK_REQUESTED, null, null); } }
Example #15
Source File: SWTUtilities.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
/** * Creates a multi-line textbox. * * @param parent a composite control which will be the parent of the new * instance (cannot be null) * @param style the style of control to construct * @param allowTabs set to <code>true</code> to allow \t characters to be * inserted. * @return the new textbox */ public static Text createMultilineTextbox(Composite parent, int style, final boolean allowTabs) { Text text = new Text(parent, style | SWT.MULTI); text.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { switch (e.detail) { case SWT.TRAVERSE_TAB_NEXT: e.doit = !allowTabs; } } }); return text; }
Example #16
Source File: InternalCompositeTable.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * Handle the keyTraversed event on any child control in the table. * * @param sender * The row sending the event. * @param e * The SWT TraverseEvent */ public void keyTraversed(TableRow sender, TraverseEvent e) { if (doMakeFocusedRowVisible()) return; if (parent.isTraverseOnTabsEnabled()) { if (e.detail == SWT.TRAVERSE_TAB_NEXT) { if (currentColumn >= sender.getNumColumns() - 1) { e.detail = SWT.TRAVERSE_NONE; handleNextRowNavigation(); } } else if (e.detail == SWT.TRAVERSE_TAB_PREVIOUS) { if (currentColumn == 0) { e.detail = SWT.TRAVERSE_NONE; handlePreviousRowNavigation(sender); } } else if (e.detail == SWT.TRAVERSE_RETURN) { e.detail = SWT.TRAVERSE_NONE; if (currentColumn >= sender.getNumColumns() - 1) { handleNextRowNavigation(); } else { deferredSetFocus(getControl(currentColumn + 1, currentRow), false); } } } else { if (e.detail == SWT.TRAVERSE_TAB_NEXT) { if (currentColumn >= sender.getNumColumns() - 1) { e.detail = SWT.TRAVERSE_NONE; } } else if (e.detail == SWT.TRAVERSE_TAB_PREVIOUS) { if (currentColumn == 0) { e.detail = SWT.TRAVERSE_NONE; } } } }
Example #17
Source File: FilteredItemsSelectionDialog.java From tlaplus with MIT License | 5 votes |
/** * Create the labels for the list and the progress. Return the list label. * * @param parent * @return Label */ private Label createLabels(Composite parent) { Composite labels = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.marginWidth = 0; layout.marginHeight = 0; labels.setLayout(layout); Label listLabel = new Label(labels, SWT.NONE); listLabel .setText(WorkbenchMessages.FilteredItemsSelectionDialog_listLabel); listLabel.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { if (e.detail == SWT.TRAVERSE_MNEMONIC && e.doit) { e.detail = SWT.TRAVERSE_NONE; list.getTable().setFocus(); } } }); GridData gd = new GridData(GridData.FILL_HORIZONTAL); listLabel.setLayoutData(gd); progressLabel = new Label(labels, SWT.RIGHT); progressLabel.setLayoutData(gd); labels.setLayoutData(gd); return listLabel; }
Example #18
Source File: FilteredItemsSelectionDialog.java From tlaplus with MIT License | 5 votes |
/** * Create a new header which is labelled by headerLabel. * * @param parent * @return Label the label of the header */ private Label createHeader(Composite parent) { Composite header = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.marginWidth = 0; layout.marginHeight = 0; header.setLayout(layout); Label headerLabel = new Label(header, SWT.NONE); headerLabel.setText((getMessage() != null && getMessage().trim() .length() > 0) ? getMessage() : WorkbenchMessages.FilteredItemsSelectionDialog_patternLabel); headerLabel.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { if (e.detail == SWT.TRAVERSE_MNEMONIC && e.doit) { e.detail = SWT.TRAVERSE_NONE; pattern.setFocus(); } } }); GridData gd = new GridData(GridData.FILL_HORIZONTAL); headerLabel.setLayoutData(gd); createViewMenu(header); header.setLayoutData(gd); return headerLabel; }
Example #19
Source File: ListenerAppender.java From ermasterr with Apache License 2.0 | 5 votes |
public static void addTraverseListener(final Text textArea) { textArea.addTraverseListener(new TraverseListener() { @Override public void keyTraversed(final TraverseEvent e) { if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) { e.doit = true; } } }); }
Example #20
Source File: SwtUtils.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
public static void disableTabTraversal(Control c) { c.addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { switch (e.detail) { case SWT.TRAVERSE_TAB_NEXT: case SWT.TRAVERSE_TAB_PREVIOUS: { e.doit = false; } } } }); }
Example #21
Source File: TableRow.java From nebula with Eclipse Public License 2.0 | 5 votes |
public void keyTraversed(TraverseEvent e) { /* * FEATURE IN SWT: When SWT needs to resolve a mnemonic (accelerator) * character, it recursively calls the traverse event down all * controls in the containership hierarchy. If e.doit is false, * no control has yet matched the mnemonic, and we don't have to * do anything since we don't do mnemonic matching and no mnemonic * has matched. */ if (e.doit) { parent.keyTraversed(TableRow.this, e); } }
Example #22
Source File: ImportDialog.java From http4e with Apache License 2.0 | 5 votes |
protected void createButtonsForButtonBar( Composite parent){ Button ok = createButton(parent, IDialogConstants.OK_ID, "Import Packet", true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); ok.addMouseListener(okListener); ok.addTraverseListener(new TraverseListener() { public void keyTraversed( TraverseEvent e){ if (SWT.TRAVERSE_RETURN == e.detail) { } } }); }
Example #23
Source File: UiUtils.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
public static void disableTabTraversal(Control c){ c.addTraverseListener(new TraverseListener () { public void keyTraversed(TraverseEvent e) { switch (e.detail) { case SWT.TRAVERSE_TAB_NEXT: case SWT.TRAVERSE_TAB_PREVIOUS: { e.doit = false; } } } }); }
Example #24
Source File: ParameterizeDialog.java From http4e with Apache License 2.0 | 5 votes |
protected void createButtonsForButtonBar( Composite parent){ Button ok = createButton(parent, IDialogConstants.OK_ID, "Close", true); // createButton(parent, IDialogConstants.CANCEL_ID, // IDialogConstants.CANCEL_LABEL, false); ok.addMouseListener(okListener); ok.addTraverseListener(new TraverseListener() { public void keyTraversed( TraverseEvent e){ if (SWT.TRAVERSE_RETURN == e.detail) { } } }); }
Example #25
Source File: HsAbstractProgressDialog.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * 运行任务的准备工作 * @return UI状态 */ @SuppressWarnings("rawtypes") private Object aboutToStart(boolean enableCancelButton) { Map savedState = null; if (getShell() != null) { // Save focus control Control focusControl = getShell().getDisplay().getFocusControl(); if (focusControl != null && focusControl.getShell() != getShell()) { focusControl = null; } boolean needsProgressMonitor = needsProgressMonitor(); // 设置Shell的鼠标状态 Display d = getShell().getDisplay(); waitCursor = new Cursor(d, SWT.CURSOR_WAIT); setDisplayCursor(waitCursor); if (useCustomProgressMonitorPart) { cancelButton.removeSelectionListener(cancelListener); // 设置取消按钮的鼠标状态 arrowCursor = new Cursor(d, SWT.CURSOR_ARROW); cancelButton.setCursor(arrowCursor); } // Deactivate shell savedState = saveUIState(useCustomProgressMonitorPart && needsProgressMonitor && enableCancelButton); if (focusControl != null) { savedState.put(FOCUS_CONTROL, focusControl); } // Activate cancel behavior. if (needsProgressMonitor) { if (enableCancelButton || useCustomProgressMonitorPart) { progressMonitorPart.attachToCancelComponent(cancelButton); } progressMonitorPart.setVisible(true); } if (timeWhenLastJobFinished == -1) { timeWhenLastJobFinished = 0; // 忽略键盘事件( enter space)在最后一个任务完成之前 getShell().addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { if (e.detail == SWT.TRAVERSE_RETURN || (e.detail == SWT.TRAVERSE_MNEMONIC && e.keyCode == 32)) { if (timeWhenLastJobFinished != 0 && System.currentTimeMillis() - timeWhenLastJobFinished < RESTORE_ENTER_DELAY) { e.doit = false; return; } timeWhenLastJobFinished = 0; } } }); } } return savedState; }
Example #26
Source File: TableView.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private void editButton( TableItem row, int rownr, int colnr ) { beforeEdit = getItemText( row ); fieldChanged = false; ColumnInfo colinfo = columns[colnr - 1]; if ( colinfo.isReadOnly() ) { return; } if ( colinfo.getDisabledListener() != null ) { boolean disabled = colinfo.getDisabledListener().isFieldDisabled( rownr ); if ( disabled ) { return; } } button = new Button( table, SWT.PUSH ); props.setLook( button, Props.WIDGET_STYLE_TABLE ); String buttonText = columns[colnr - 1].getButtonText(); if ( buttonText != null ) { button.setText( buttonText ); } button.setImage( GUIResource.getInstance().getImage( "ui/images/edittext.svg" ) ); SelectionListener selAdpt = colinfo.getSelectionAdapter(); if ( selAdpt != null ) { button.addSelectionListener( selAdpt ); } buttonRownr = rownr; buttonColnr = colnr; // button.addTraverseListener(lsTraverse); buttonContent = row.getText( colnr ); String tooltip = columns[colnr - 1].getToolTip(); if ( tooltip != null ) { button.setToolTipText( tooltip ); } else { button.setToolTipText( "" ); } button.addTraverseListener( lsTraverse ); // hop to next field button.addTraverseListener( new TraverseListener() { @Override public void keyTraversed( TraverseEvent arg0 ) { closeActiveButton(); } } ); editor.horizontalAlignment = SWT.LEFT; editor.verticalAlignment = SWT.TOP; editor.grabHorizontal = false; editor.grabVertical = false; Point size = button.computeSize( SWT.DEFAULT, SWT.DEFAULT ); editor.minimumWidth = size.x; editor.minimumHeight = size.y - 2; // setRowNums(); editor.layout(); // Open the text editor in the correct column of the selected row. editor.setEditor( button ); button.setFocus(); // if the button loses focus, destroy it... /* * button.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent e) { button.dispose(); } } ); */ }
Example #27
Source File: AbstractSelectableRow.java From nebula with Eclipse Public License 2.0 | 4 votes |
public void keyTraversed(TraverseEvent e) { // NOOP: this just lets us receive focus from SWT }
Example #28
Source File: ProcessSearchPage.java From olca-app with Mozilla Public License 2.0 | 4 votes |
@Override public void keyTraversed(TraverseEvent e) { if (e.detail == SWT.TRAVERSE_RETURN) runSearch(text.getText()); }
Example #29
Source File: EmptyTablePlaceholder.java From nebula with Eclipse Public License 2.0 | 4 votes |
public void keyTraversed(TraverseEvent e) { }
Example #30
Source File: TimeSlot.java From nebula with Eclipse Public License 2.0 | 4 votes |
public void keyTraversed(TraverseEvent e) { // NOOP: this just lets us receive focus from SWT }