public static interface Widget.KeyPressEvent
Enter key while the pointer
is over a Button, but then move the mouse off of that Button,
subsequently releasing won't cause that Button to activate).
When hooking this up, you'll probably be wanting the key that was hit.
That's accomplished with Call event.getKeyval() as in:
foo.connect(new Widget.KeyPressEvent() {
public boolean onKeyPressEvent(Widget source, EventKey event) {
final Keyval key;
final ModifierType mod;
key = event.getKeyval();
mod = event.getState();
if (key == Keyval.Up) {
// go up!
}
return false;
}
});
but see Keyval for a long discussion of
the interpretation and use of keystrokes. Also note that reacting to a
key stroke does not imply intercepting it; returning false
and letting the default handlers in GTK carry on with things is usually
what you want to do.
The release half of this is Widget.KeyReleaseEvent as you might
expect.
| Modifier and Type | Method and Description |
|---|---|
boolean |
onKeyPressEvent(Widget source,
EventKey event)
As with other event signals, returning
false means "I
didn't [fully] handle this signal, so proceed with the next (ie,
usually the default) handler" whereas if you return
true you mean "I have handled this event, and wish to
stop further emission of the signal". |
boolean onKeyPressEvent(Widget source, EventKey event)
false means "I
didn't [fully] handle this signal, so proceed with the next (ie,
usually the default) handler" whereas if you return
true you mean "I have handled this event, and wish to
stop further emission of the signal".