/** Posts a key event received from elsewhere (i.e. a native UI component). This is useful for * applications that are using GL in Canvas mode and sharing keyboard focus with other (non-GL) * components. The event will be queued and dispatched on the next frame, after GL keyboard * events. * * @param time the time (in millis since epoch) at which the event was generated, or 0 if N/A. * @param key the key that was pressed or released, or null for a char typed event * @param pressed whether the key was pressed or released, ignored if key is null * @param typedCh the character that was typed, ignored if key is not null * @param modFlags modifier key state flags (generated by {@link #modifierFlags}) */ public void postKey (long time, Key key, boolean pressed, char typedCh, int modFlags) { kevQueue.add(key == null ? new Keyboard.TypedEvent(modFlags, time, typedCh) : new Keyboard.KeyEvent(modFlags, time, key, pressed)); }
case D: Layer.DEBUG_RECTS = event.down; if (event.down && event.isShiftDown()) { rootLayer.debugPrint(log);
/** Posts a key event received from elsewhere (i.e. a native UI component). This is useful for * applications that are using GL in Canvas mode and sharing keyboard focus with other (non-GL) * components. The event will be queued and dispatched on the next frame, after GL keyboard * events. * * @param time the time (in millis since epoch) at which the event was generated, or 0 if N/A. * @param key the key that was pressed or released, or null for a char typed event * @param pressed whether the key was pressed or released, ignored if key is null * @param typedCh the character that was typed, ignored if key is not null * @param modFlags modifier key state flags (generated by {@link #modifierFlags}) */ public void postKey (long time, Key key, boolean pressed, char typedCh, int modFlags) { kevQueue.add(key == null ? new Keyboard.TypedEvent(modFlags, time, typedCh) : new Keyboard.KeyEvent(modFlags, time, key, pressed)); }
public TripleDemo (Platform plat) { super(plat, 25); // update our "simulation" 40 times per second game = this; // jam ourselves into a global variable, woo! new Pointer(plat, rootLayer, true); // wire up event dispatch screens.push(new DemoMenuScreen(screens)); // start off with our menu screen // show debug rectangles when D key is pressed; dump scene graph on shift-D plat.input().keyboardEvents.collect(Keyboard.isKey(Key.D)).connect(event -> { Layer.DEBUG_RECTS = event.down; if (event.down && event.isShiftDown()) { rootLayer.debugPrint(plat.log()); } }); } }
@Override public void handleEvent(NativeEvent nevent) { Key key = keyForCode(nevent.getKeyCode()); dispatch(new Keyboard.KeyEvent(0, plat.time(), key, false), nevent); } });
@Override public void handleEvent(NativeEvent nevent) { Key key = keyForCode(nevent.getKeyCode()); dispatch(new Keyboard.KeyEvent(0, plat.time(), key, false), nevent); } });
protected void emitKeyPress (int flags, double time, Key key, boolean down) { if (keyboardEnabled) { plat.dispatchEvent(keyboardEvents, new Keyboard.KeyEvent(flags, time, key, down)); } } protected void emitKeyTyped (double time, char keyChar) {
void onKeyDown (int keyCode, KeyEvent nativeEvent) { long time = nativeEvent.getEventTime(); Keyboard.KeyEvent event = new Keyboard.KeyEvent(0, time, keyForCode(keyCode), true); event.setFlag(mods(nativeEvent)); dispatch(event); int unicodeChar = nativeEvent.getUnicodeChar(); if (unicodeChar != 0) dispatch(new Keyboard.TypedEvent(0, time, (char)unicodeChar)); }
@Override public void handleEvent(NativeEvent nevent) { Key key = keyForCode(nevent.getKeyCode()); dispatch(new Keyboard.KeyEvent(0, plat.time(), key, true), nevent); } });
void onKeyUp (int keyCode, KeyEvent nativeEvent) { long time = nativeEvent.getEventTime(); Keyboard.KeyEvent event = new Keyboard.KeyEvent(0, time, keyForCode(keyCode), false); event.setFlag(mods(nativeEvent)); dispatch(event); }
protected void emitKeyPress (int flags, double time, Key key, boolean down) { if (keyboardEnabled) { plat.dispatchEvent(keyboardEvents, new Keyboard.KeyEvent(flags, time, key, down)); } } protected void emitKeyTyped (double time, char keyChar) {
@Override public void handleEvent(NativeEvent nevent) { Key key = keyForCode(nevent.getKeyCode()); dispatch(new Keyboard.KeyEvent(0, plat.time(), key, true), nevent); } });