本文整理了Java中org.eclipse.swt.events.KeyEvent
类的一些代码示例,展示了KeyEvent
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyEvent
类的具体详情如下:
包路径:org.eclipse.swt.events.KeyEvent
类名称:KeyEvent
[英]Instances of this class are sent as a result of keys being pressed and released on the keyboard.
When a key listener is added to a control, the control will take part in widget traversal. By default, all traversal keys (such as the tab key and so on) are delivered to the control. In order for a control to take part in traversal, it should listen for traversal events. Otherwise, the user can traverse into a control but not out. Note that native controls such as table and tree implement key traversal in the operating system. It is not necessary to add traversal listeners for these controls, unless you want to override the default traversal.
[中]此类的实例是在键盘上按下和释放键后发送的。
将密钥侦听器添加到控件时,该控件将参与小部件遍历。默认情况下,所有遍历键(如tab键等)都传递给控件。为了让控件参与遍历,它应该侦听遍历事件。否则,用户可以遍历到控件中,但不能遍历出控件。请注意,本机控件(如表和树)在操作系统中实现键遍历。除非要覆盖默认遍历,否则无需为这些控件添加遍历侦听器。
代码示例来源:origin: pentaho/pentaho-kettle
@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;
}
}
代码示例来源:origin: Renanse/Ardor3D
@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);
}
代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64
/**
* 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
+ "}";
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
switch (event.type) {
case SWT.KeyDown:
case SWT.KeyUp: toString += new KeyEvent (event).toString (); break;
case SWT.MouseDown:
case SWT.MouseUp:
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt.q07
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 );
}
}
} );
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt.q07
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 );
}
}
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text
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 :
代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64
/**
* 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
+ "}";
}
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt.q07
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 ) ) );
代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text
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 :
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86
/**
* 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
+ "}";
}
}
代码示例来源:origin: org.piccolo2d/piccolo2d-swt
/** {@inheritDoc} */
public Object getSource() {
return swtEvent.getSource();
}
代码示例来源:origin: org.microemu/microemu-javase-swt
Event event = new Event();
event.widget = e.widget;
KeyEvent ev = new KeyEvent(event);
ev.keyCode = pressedButton.getKeyCode();
inputMethod.mousePressed(ev);
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.s390x
/**
* 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
+ "}";
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ant.ui
@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);
}
}
}
};
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
KeyEvent event = new KeyEvent(e);
((KeyListener) eventListener).keyPressed(event);
e.doit = event.doit;
KeyEvent event = new KeyEvent(e);
((KeyListener) eventListener).keyReleased(event);
e.doit = event.doit;
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc
/**
* 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
+ "}";
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.debug.ui
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;
}
}
}
代码示例来源:origin: org.eclipse.swt.cocoa.macosx/x86_64
KeyEvent event = new KeyEvent(e);
((KeyListener) eventListener).keyPressed(event);
e.doit = event.doit;
KeyEvent event = new KeyEvent(e);
((KeyListener) eventListener).keyReleased(event);
e.doit = event.doit;
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.aix.ppc
/**
* 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
+ "}";
}
}
内容来源于网络,如有侵权,请联系作者删除!