Java Code Examples for org.eclipse.swt.SWT#MOD1
The following examples show how to use
org.eclipse.swt.SWT#MOD1 .
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: Gallery.java From nebula with Eclipse Public License 2.0 | 6 votes |
void onMouseUp(Event e) { if (DEBUG) System.out.println("onMouseUp"); //$NON-NLS-1$ if (mouseClickHandled) { if (DEBUG) { System.out.println("onMouseUp : mouse event already handled"); //$NON-NLS-1$ } return; } if (e.button == 1) { GalleryItem item = getItem(new Point(e.x, e.y)); if (item == null) return; if ((e.stateMask & SWT.MOD1) > 0) { onMouseHandleLeftMod1(e, item, false, true); } else if ((e.stateMask & SWT.SHIFT) > 0) { onMouseHandleLeftShift(e, item, false, true); } else { onMouseHandleLeft(e, item, false, true); } } }
Example 2
Source File: ShortcutListener.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
public void verifyKey(VerifyEvent event){ if (event.stateMask == SWT.MOD1) { switch (event.keyCode) { // 'z' case 122: System.out.println("undo"); mine.undo(); event.doit = false; break; /* * already handled by StyledText itself // 'c' case 99: System.out.println("copy"); * mine.text.copy(); break; // 'v' case 118: System.out.print("paste"); * mine.text.paste(); break; */ default: System.out.println(event.toString()); } /* * don't ignore any other CTRL shortcuts! event.doit=false; */ } else event.doit = true; }
Example 3
Source File: CompletionProposalPopup.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * @see org.eclipse.swt.events.KeyListener#keyReleased(org.eclipse.swt.events.KeyEvent) */ public void keyReleased(KeyEvent e) { if (!Helper.okToUse(fProposalShell)) { return; } if (e.character == 0 && e.keyCode == SWT.MOD1) { // http://dev.eclipse.org/bugs/show_bug.cgi?id=34754 int index = fProposalTable.getSelectionIndex(); if (index >= 0) { selectProposal(index, false, true); } // else // { // fProposalTable.setTopIndex(0); // } } }
Example 4
Source File: CompletionProposalPopup.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * @see org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent) */ public void keyPressed(KeyEvent e) { if (!Helper.okToUse(fProposalShell)) { return; } if (e.character == 0 && e.keyCode == SWT.MOD1) { // http://dev.eclipse.org/bugs/show_bug.cgi?id=34754 int index = fProposalTable.getSelectionIndex(); if (index >= 0) { selectProposal(index, true, true); } // else // { // fProposalTable.setTopIndex(0); // } } }
Example 5
Source File: EditTemplateDialog.java From typescript.java with MIT License | 6 votes |
private void handleVerifyKeyPressed(VerifyEvent event) { if (!event.doit) return; if (event.stateMask != SWT.MOD1) return; switch (event.character) { case ' ': fPatternEditor.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS); event.doit = false; break; // CTRL-Z case 'z' - 'a' + 1: fPatternEditor.doOperation(ITextOperationTarget.UNDO); event.doit = false; break; } }
Example 6
Source File: TypeScriptCompletionProposal.java From typescript.java with MIT License | 6 votes |
@Override public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) { initIfNeeded(); IDocument document = viewer.getDocument(); if (fTextViewer == null) { fTextViewer = viewer; } // don't eat if not in preferences, XOR with modifier key 1 (Ctrl) // but: if there is a selection, replace it! Point selection = viewer.getSelectedRange(); fToggleEating = (stateMask & SWT.MOD1) != 0; int newLength = selection.x + selection.y - getReplacementOffset(); if ((insertCompletion() ^ fToggleEating) && newLength >= 0) { setReplacementLength(newLength); } apply(document, trigger, offset); fToggleEating = false; }
Example 7
Source File: MenuManager.java From pmTrans with GNU Lesser General Public License v3.0 | 6 votes |
private MenuItem addConfigurableMenuItem(Menu menu, final String orgText, final String acceleratorKey, SelectionListener listener) { char accelerator = Config.getInstance().getString(acceleratorKey) .toUpperCase().charAt(0); int acc = SWT.MOD1 + (accelerator == ' ' ? SWT.SPACE : accelerator); String text = orgText + " \t Ctrl+" + (accelerator == ' ' ? "[space]" : accelerator); final MenuItem item = addMenuItem(menu, text, acc, listener); Config.getInstance().addPropertyChangeListener( new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent arg0) { if (arg0.getProperty().equals(acceleratorKey)) updateAccelerator(item, orgText, Config .getInstance().getString(acceleratorKey) .toUpperCase().charAt(0)); } }); return item; }
Example 8
Source File: MouseTransformer.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override public void onMouseDown ( final MouseState e ) { if ( e.button != 1 || e.state != SWT.MOD1 ) { return; } final Rectangle rect = this.chartArea.getClientAreaProxy ().getClientRectangle (); // check if we are outside the chart area if ( e.x < rect.x || e.x > rect.x + rect.width ) { return; } if ( e.y < rect.y || e.y > rect.y + rect.height ) { return; } // now start dragging this.active = true; this.startX = e.x; this.startY = e.y; }
Example 9
Source File: MenuManager.java From pmTrans with GNU Lesser General Public License v3.0 | 5 votes |
private void updateAccelerator(MenuItem item, String itemText, char newAccelerator) { itemText += " \t Ctrl+" + (newAccelerator == ' ' ? "[space]" : newAccelerator); int acc = SWT.MOD1 + (newAccelerator == ' ' ? SWT.SPACE : newAccelerator); item.setText(itemText); item.setAccelerator(acc); }
Example 10
Source File: ContextInformationPopup.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Processes a key stroke while the info popup is up. * * @param e * the verify event describing the key stroke * @return <code>true</code> if processing can be stopped */ private boolean contextInfoPopupKeyPressed(KeyEvent e) { char key = e.character; if (key == 0) { switch (e.keyCode) { case SWT.ARROW_LEFT: case SWT.ARROW_RIGHT: case SWT.ARROW_UP: case SWT.ARROW_DOWN: validateContextInformation(); break; default: if (e.keyCode != SWT.CAPS_LOCK && e.keyCode != SWT.MOD1 && e.keyCode != SWT.MOD2 && e.keyCode != SWT.MOD3 && e.keyCode != SWT.MOD4) { hideContextInfoPopup(); } break; } } else if (key == SWT.ESC) { e.doit = false; hideContextInfoPopup(); } else { validateContextInformation(); } return true; }
Example 11
Source File: Gallery.java From nebula with Eclipse Public License 2.0 | 5 votes |
void onMouseDown(Event e) { if (DEBUG) System.out.println("Mouse down "); //$NON-NLS-1$ mouseClickHandled = false; if (!_mouseDown(e)) { // Stop handling as requested by the group renderer mouseClickHandled = true; return; } GalleryItem item = getItem(new Point(e.x, e.y)); if (e.button == 1) { if (item == null) { _deselectAll(true); redraw(); mouseClickHandled = true; lastSingleClick = null; } else { if ((e.stateMask & SWT.MOD1) > 0) { onMouseHandleLeftMod1(e, item, true, false); } else if ((e.stateMask & SWT.SHIFT) > 0) { onMouseHandleLeftShift(e, item, true, false); } else { onMouseHandleLeft(e, item, true, false); } } } else if (e.button == 3) { onMouseHandleRight(e, item, true, false); } }
Example 12
Source File: ContentAssistant.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * @param offset * @param document */ private boolean isValidAutoAssistLocation(KeyEvent e, StyledText styledText) { // Don't pop up CA if we pressed a Ctrl or Command character. On Linux, Unicode characters can be inserted with // Ctrl + Shift + u + key sequence, but at this point, all we get is the character, no modifiers. if (e.stateMask == SWT.MOD1) { return false; } int keyCode = e.keyCode; if (keyCode == SWT.ESC || keyCode == SWT.BS || keyCode == SWT.DEL || keyCode == SWT.ARROW || (keyCode & SWT.KEYCODE_BIT) != 0) { return false; } int offset = styledText.getCaretOffset(); IContentAssistProcessor processor = getProcessor(fContentAssistSubjectControlAdapter, offset); if (processor instanceof ICommonContentAssistProcessor) { ICommonContentAssistProcessor cp = (ICommonContentAssistProcessor) processor; // are we typing a valid identifier, and the previous "location" (character or lexeme) should pop up CA return cp.isValidIdentifier(e.character, keyCode) && isAutoActivationLocation(cp, styledText, e.character, keyCode); } else { return false; } }
Example 13
Source File: ControlSpaceKeyAdapter.java From hop with Apache License 2.0 | 5 votes |
/** * PDI-1284 in chinese window, Ctrl-SPACE is reversed by system for input chinese character. use Ctrl-ALT-SPACE * instead. * * @param e * @return */ private boolean isHotKey( KeyEvent e ) { if ( System.getProperty( "user.language" ).equals( "zh" ) ) { return e.character == ' ' && ( ( e.stateMask & SWT.CONTROL ) != 0 ) && ( ( e.stateMask & SWT.ALT ) != 0 ); } else if ( System.getProperty( "os.name" ).startsWith( "Mac OS X" ) ) { return e.character == ' ' && ( ( e.stateMask & SWT.MOD1 ) != 0 ) && ( ( e.stateMask & SWT.ALT ) == 0 ); } else { return e.character == ' ' && ( ( e.stateMask & SWT.CONTROL ) != 0 ) && ( ( e.stateMask & SWT.ALT ) == 0 ); } }
Example 14
Source File: ControlSpaceKeyAdapter.java From pentaho-kettle with Apache License 2.0 | 5 votes |
/** * PDI-1284 in chinese window, Ctrl-SPACE is reversed by system for input chinese character. use Ctrl-ALT-SPACE * instead. * * @param e * @return */ private boolean isHotKey( KeyEvent e ) { if ( System.getProperty( "user.language" ).equals( "zh" ) ) { return e.character == ' ' && ( ( e.stateMask & SWT.CONTROL ) != 0 ) && ( ( e.stateMask & SWT.ALT ) != 0 ); } else if ( System.getProperty( "os.name" ).startsWith( "Mac OS X" ) ) { return e.character == ' ' && ( ( e.stateMask & SWT.MOD1 ) != 0 ) && ( ( e.stateMask & SWT.ALT ) == 0 ); } else { return e.character == ' ' && ( ( e.stateMask & SWT.CONTROL ) != 0 ) && ( ( e.stateMask & SWT.ALT ) == 0 ); } }
Example 15
Source File: TableViewPainted.java From BiglyBT with GNU General Public License v2.0 | 4 votes |
@Override public void enableFilterCheck( Text txtFilter, TableViewFilterCheck<Object> filterCheck, boolean filterSubRows ) { this.filterSubRows = filterSubRows; TableViewSWTFilter<?> filter = getSWTFilter(); if (filter != null) { if (filter.widget != null && !filter.widget.isDisposed()) { filter.widget.removeKeyListener(tvSWTCommon); filter.widget.removeKeyListener(filter.widgetKeyListener); filter.widget.removeModifyListener(filter.widgetModifyListener); } } else { this.filter = filter = new TableViewSWTFilter(); } filter.widget = txtFilter; if (txtFilter != null) { Class<?> cla = getDataSourceType(); String historyKey = ""; if ( cla != null ){ if ( cla == DownloadTypeComplete.class || cla == DownloadTypeIncomplete.class || cla == Download.class ){ // default, leave blank }else{ historyKey = "." + cla.getName(); // different history for different table types } } // must create this before adding other listeners so it gets priority over key events TextWithHistory twh = new TextWithHistory( "tableviewpainted.search" + historyKey, "table.filter.history", txtFilter ); // disable as interferes with key-down into search results feature twh.setKeDownShowsHistory( false ); txtFilter.addListener( SWT.FocusOut, (ev)->{ String text = txtFilter.getText().trim(); if ( !text.isEmpty()){ twh.addHistory( text ); } }); txtFilter.addKeyListener(tvSWTCommon); filter.widgetModifyListener = new ModifyListener() { @Override public void modifyText(ModifyEvent e) { setFilterText(((Text) e.widget).getText()); } }; txtFilter.addModifyListener(filter.widgetModifyListener); final TableViewSWTFilter f_filter = filter; filter.widgetKeyListener = new KeyAdapter(){ public void keyPressed(KeyEvent event){ int key = event.character; if (key <= 26 && key > 0) { key += 'a' - 1; } if (event.stateMask == SWT.MOD1) { switch (key) { case 'x': { // CTRL+X: RegEx search switch f_filter.regex = !f_filter.regex; tvSWTCommon.validateFilterRegex(); refilter(); event.doit = false; // prevent sound from this key } break; } } }}; txtFilter.addKeyListener(filter.widgetKeyListener); if (txtFilter.getText().length() == 0) { txtFilter.setText(filter.text); } else { filter.text = filter.nextText = txtFilter.getText(); } } else { filter.text = filter.nextText = ""; } filter.checker = filterCheck; filter.checker.filterSet(filter.text); refilter(); }
Example 16
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 17
Source File: AbstractSettings.java From nebula with Eclipse Public License 2.0 | 4 votes |
public int getZoomWheelModifierKey() { return SWT.MOD1; }
Example 18
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 19
Source File: SelectableControlList.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 2 votes |
/** * Internal to ControlList * * @param stateMask * @return */ boolean ctrlClicked(int stateMask) { return (SWT.MOD1 & stateMask) != 0; }