@Override public void keyPressed( KeyEvent keyEvent ) { int state = keyEvent.stateMask, key = keyEvent.keyCode; boolean copyContent = state == SWT.CTRL && key == SWT.F6, arrowNavigation = ( state == SWT.COMMAND || state == SWT.ALT ) && ( key == SWT.ARROW_LEFT || key == SWT.ARROW_RIGHT ), backslashNavigation = ( state == SWT.SHIFT && key == SWT.BS ), reloadContent = state == SWT.CTRL && ( key == SWT.F5 || key == 114 /* r key */ ) || key == SWT.F5, zoomContent = state == SWT.CTRL && ( key == SWT.KEYPAD_ADD || key == SWT.KEYPAD_SUBTRACT || key == 61 /* + key */ || key == 45 /* - key */ ); if ( copyContent ) { Browser thisBrowser = (Browser) keyEvent.getSource(); Clipboard clipboard = new Clipboard( thisBrowser.getDisplay() ); clipboard.setContents( new String[] { lastNavigateURL }, new Transfer[] { TextTransfer.getInstance() } ); clipboard.dispose(); } else if ( arrowNavigation || backslashNavigation || reloadContent || zoomContent ) { keyEvent.doit = false; } }
@Before public void setup() throws Exception { control = createMock("control", SwtCanvas.class); kw = new SwtKeyboardWrapper(control); final Event event = new Event(); event.widget = control; e1 = new org.eclipse.swt.events.KeyEvent(event); e2 = new org.eclipse.swt.events.KeyEvent(event); }
/** * Returns a string containing a concise, human-readable * description of the receiver. * * @return a string representation of the event */ public String toString() { String string = super.toString (); return string.substring (0, string.length() - 1) // remove trailing '}' + " detail=" + detail + "}"; } }
public void run() { boolean allow = true; if( traverseKey != SWT.TRAVERSE_NONE ) { TraverseEvent traverseEvent = new TraverseEvent( control ); initializeKeyEvent( traverseEvent, keyCode, charCode, stateMask ); traverseEvent.detail = traverseKey; traverseEvent.processEvent(); if( !traverseEvent.doit ) { allow = false; } } KeyEvent pressedEvent = new KeyEvent( control, KeyEvent.KEY_PRESSED ); initializeKeyEvent( pressedEvent, keyCode, charCode, stateMask ); pressedEvent.processEvent(); if( pressedEvent.doit ) { KeyEvent releasedEvent = new KeyEvent( control, KeyEvent.KEY_RELEASED ); initializeKeyEvent( releasedEvent, keyCode, charCode, stateMask ); releasedEvent.processEvent(); } else { allow = false; } if( allow ) { allowKeyEvent( control ); } else { cancelKeyEvent( control ); } } } );
static void writeKeyListener( Control control ) throws IOException { String prop = PROP_KEY_LISTENER; Boolean hasListener = Boolean.valueOf( KeyEvent.hasListener( control ) ); Boolean defValue = Boolean.FALSE; if( WidgetLCAUtil.hasChanged( control, prop, hasListener, defValue ) ) { JSWriter writer = JSWriter.getWriterFor( control ); if( hasListener.booleanValue() ) { Object[] args = new Object[] { USER_DATA_KEY_LISTENER, hasListener }; writer.call( "setUserData", args ); } else { Object[] args = new Object[] { USER_DATA_KEY_LISTENER, null }; writer.call( "setUserData", args ); } } }
return; //SWT.TRAVERSE_MNEMONIC events can also come in to inactive widgets VerifyEvent verifyEvent= new VerifyEvent(e); KeyEvent keyEvent= new KeyEvent(e); switch (e.type) { case SWT.Traverse :
/** * Returns a string containing a concise, human-readable * description of the receiver. * * @return a string representation of the event */ public String toString() { String string = super.toString (); return string.substring (0, string.length() - 1) // remove trailing '}' + " start=" + start + " end=" + end + " text=" + text + "}"; } }
adapter.preserve( PROP_FOCUS_LISTENER, Boolean.valueOf( FocusEvent.hasListener( control ) ) ); adapter.preserve( PROP_KEY_LISTENER, Boolean.valueOf( KeyEvent.hasListener( control ) ) ); adapter.preserve( PROP_TRAVERSE_LISTENER, Boolean.valueOf( TraverseEvent.hasListener( control ) ) );
return; //SWT.TRAVERSE_MNEMONIC events can also come in to inactive widgets VerifyEvent verifyEvent= new VerifyEvent(e); KeyEvent keyEvent= new KeyEvent(e); switch (e.type) { case SWT.Traverse :
/** * Returns a string containing a concise, human-readable * description of the receiver. * * @return a string representation of the event */ @Override public String toString() { String string = super.toString (); return string.substring (0, string.length() - 1) // remove trailing '}' + " detail=" + detail + "}"; } }
/** {@inheritDoc} */ public Object getSource() { return swtEvent.getSource(); }
Event event = new Event(); event.widget = e.widget; KeyEvent ev = new KeyEvent(event); ev.keyCode = pressedButton.getKeyCode(); inputMethod.mousePressed(ev);
/** * Returns a string containing a concise, human-readable * description of the receiver. * * @return a string representation of the event */ @Override public String toString() { String string = super.toString (); return string.substring (0, string.length() - 1) // remove trailing '}' + " detail=" + detail + "}"; } }
@Override public void keyPressed(KeyEvent event) { if (event.getSource() == propertyTableViewer) { if (removeButton.isEnabled() && event.character == SWT.DEL && event.stateMask == 0) { remove(propertyTableViewer); } } else if (event.getSource() == fileTableViewer) { if (removeFileButton.isEnabled() && event.character == SWT.DEL && event.stateMask == 0) { remove(fileTableViewer); } } } };
/** * Returns a string containing a concise, human-readable * description of the receiver. * * @return a string representation of the event */ @Override public String toString() { String string = super.toString (); return string.substring (0, string.length() - 1) // remove trailing '}' + " start=" + start + " end=" + end + " text=" + text + "}"; } }
private void handleCursorKeyPressed(KeyEvent event) { // allow edit if user hits return if (event.character == '\r' && event.getSource() instanceof TableCursor) { activateCellEditor(null); return; } if (MemoryViewUtil.isValidEditEvent(event.keyCode)) { // activate edit as soon as user types something at the cursor if (event.getSource() instanceof TableCursor) { String initialValue = String.valueOf(event.character); activateCellEditor(initialValue); return; } } }
/** * Returns a string containing a concise, human-readable * description of the receiver. * * @return a string representation of the event */ @Override public String toString() { String string = super.toString (); return string.substring (0, string.length() - 1) // remove trailing '}' + " start=" + start + " end=" + end + " text=" + text + "}"; } }