Java Code Examples for javafx.scene.input.KeyEvent#KEY_TYPED

The following examples show how to use javafx.scene.input.KeyEvent#KEY_TYPED . 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: ShowPanel.java    From oim-fx with MIT License 6 votes vote down vote up
public void processKeyEvent(KeyEvent ev) {
	if (webPage == null)
		return;
	ev.consume();
	String text = null;
	String keyIdentifier = null;
	int windowsVirtualKeyCode = 0;
	if (ev.getEventType() == KeyEvent.KEY_TYPED) {
		text = ev.getCharacter();
	} else {
		KeyCodeMap.Entry keyCodeEntry = KeyCodeMap.lookup(ev.getCode());
		keyIdentifier = keyCodeEntry.getKeyIdentifier();
		windowsVirtualKeyCode = keyCodeEntry.getWindowsVirtualKeyCode();
	}

	WCKeyEvent keyEvent = new WCKeyEvent(
			idMap.get(ev.getEventType()),
			text,
			keyIdentifier,
			windowsVirtualKeyCode,
			ev.isShiftDown(), ev.isControlDown(),
			ev.isAltDown(), ev.isMetaDown(), System.currentTimeMillis());
	if (webPage.dispatchKeyEvent(keyEvent)) {
		ev.consume();
	}
}
 
Example 2
Source File: WebViewEventDispatcher.java    From oim-fx with MIT License 6 votes vote down vote up
private void processKeyEvent(KeyEvent ev) {
    if (page == null) return;

    String text = null;
    String keyIdentifier = null;
    int windowsVirtualKeyCode = 0;
    if(ev.getEventType() == KeyEvent.KEY_TYPED) {
        text = ev.getCharacter();
    } else {
        KeyCodeMap.Entry keyCodeEntry = KeyCodeMap.lookup(ev.getCode());
        keyIdentifier = keyCodeEntry.getKeyIdentifier();
        windowsVirtualKeyCode = keyCodeEntry.getWindowsVirtualKeyCode();
    }

    WCKeyEvent keyEvent = new WCKeyEvent(
            idMap.get(ev.getEventType()),
            text,
            keyIdentifier,
            windowsVirtualKeyCode,
            ev.isShiftDown(), ev.isControlDown(),
            ev.isAltDown(), ev.isMetaDown(), System.currentTimeMillis());
    if (page.dispatchKeyEvent(keyEvent)) {
        ev.consume();
    }
}
 
Example 3
Source File: WritePane.java    From oim-fx with MIT License 6 votes vote down vote up
private void processKeyEvent(KeyEvent ev) {
	if (webPage == null)
		return;

	String text = null;
	String keyIdentifier = null;
	int windowsVirtualKeyCode = 0;
	if (ev.getEventType() == KeyEvent.KEY_TYPED) {
		text = ev.getCharacter();
	} else {
		KeyCodeMap.Entry keyCodeEntry = KeyCodeMap.lookup(ev.getCode());
		keyIdentifier = keyCodeEntry.getKeyIdentifier();
		windowsVirtualKeyCode = keyCodeEntry.getWindowsVirtualKeyCode();
	}
	System.out.println(ev.getText());
	WCKeyEvent keyEvent = new WCKeyEvent(
			idMap.get(ev.getEventType()),
			text,
			keyIdentifier,
			windowsVirtualKeyCode,
			ev.isShiftDown(), ev.isControlDown(),
			ev.isAltDown(), ev.isMetaDown(), System.currentTimeMillis());
	if (webPage.dispatchKeyEvent(keyEvent)) {
		ev.consume();
	}
}
 
Example 4
Source File: WritePanel.java    From oim-fx with MIT License 5 votes vote down vote up
public void processKeyEvent(KeyEvent ev) {
	if (webPage == null)
		return;
	ev.consume();
	String text = null;
	String keyIdentifier = null;
	int windowsVirtualKeyCode = 0;
	if (ev.getEventType() == KeyEvent.KEY_TYPED) {
		text = ev.getCharacter();
	} else {
		System.out.println(ev.getCode());
		KeyCodeMap.Entry keyCodeEntry = KeyCodeMap.lookup(ev.getCode());
		keyIdentifier = keyCodeEntry.getKeyIdentifier();
		windowsVirtualKeyCode = keyCodeEntry.getWindowsVirtualKeyCode();
	}

	WCKeyEvent keyEvent = new WCKeyEvent(
			idMap.get(ev.getEventType()),
			text,
			keyIdentifier,
			windowsVirtualKeyCode,
			ev.isShiftDown(), ev.isControlDown(),
			ev.isAltDown(), ev.isMetaDown(), System.currentTimeMillis());
	if (webPage.dispatchKeyEvent(keyEvent)) {
		ev.consume();
	}
}
 
Example 5
Source File: ChatShowPane.java    From oim-fx with MIT License 5 votes vote down vote up
public void processKeyEvent(KeyEvent ev) {
	if (webPage == null){
		return;
	}
	ev.consume();
	String text = null;
	String keyIdentifier = null;
	int windowsVirtualKeyCode = 0;
	if (ev.getEventType() == KeyEvent.KEY_TYPED) {
		text = ev.getCharacter();
	} else {
		KeyCodeMap.Entry keyCodeEntry = KeyCodeMap.lookup(ev.getCode());
		keyIdentifier = keyCodeEntry.getKeyIdentifier();
		windowsVirtualKeyCode = keyCodeEntry.getWindowsVirtualKeyCode();
	}

	WCKeyEvent keyEvent = new WCKeyEvent(
			idMap.get(ev.getEventType()),
			text,
			keyIdentifier,
			windowsVirtualKeyCode,
			ev.isShiftDown(), ev.isControlDown(),
			ev.isAltDown(), ev.isMetaDown(), System.currentTimeMillis());
	if (webPage.dispatchKeyEvent(keyEvent)) {
		ev.consume();
	}
}
 
Example 6
Source File: ChatWritePane.java    From oim-fx with MIT License 5 votes vote down vote up
public void processKeyEvent(KeyEvent ev) {
	if (webPage == null)
		return;
	ev.consume();
	String text = null;
	String keyIdentifier = null;
	int windowsVirtualKeyCode = 0;
	if (ev.getEventType() == KeyEvent.KEY_TYPED) {
		text = ev.getCharacter();
	} else {
		System.out.println(ev.getCode());
		KeyCodeMap.Entry keyCodeEntry = KeyCodeMap.lookup(ev.getCode());
		keyIdentifier = keyCodeEntry.getKeyIdentifier();
		windowsVirtualKeyCode = keyCodeEntry.getWindowsVirtualKeyCode();
	}

	WCKeyEvent keyEvent = new WCKeyEvent(
			idMap.get(ev.getEventType()),
			text,
			keyIdentifier,
			windowsVirtualKeyCode,
			ev.isShiftDown(), ev.isControlDown(),
			ev.isAltDown(), ev.isMetaDown(), System.currentTimeMillis());
	if (webPage.dispatchKeyEvent(keyEvent)) {
		ev.consume();
	}
}
 
Example 7
Source File: ConsoleKeyEvent.java    From xframium-java with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void handle (KeyEvent e)                     // onKeyTyped
{
  if (e.getEventType () != KeyEvent.KEY_TYPED)
    return;
  String c = e.getCharacter ();
  if (c.isEmpty ())
    return;
  char ch = c.charAt (0);

  if (screen.isKeyboardLocked () || e.isMetaDown () || e.isControlDown ()
      || e.isAltDown ())
  {
    // seems to be a bug in java
    if (e.isMetaDown ())
    {
      if (ch == '-')                    // osx fix
      {
        screen.getFontManager ().smaller ();
        e.consume ();
      }
      else if (ch == '=')               // osx fix
      {
        screen.getFontManager ().bigger ();
        e.consume ();
      }
    }

    return;
  }

  if (ch >= 32 && ch < 0x7F)
  {
    cursor.typeChar ((byte) Dm3270Utility.asc2ebc[ch]);
    e.consume ();
  }
}
 
Example 8
Source File: ConsoleKeyEvent.java    From dm3270 with Apache License 2.0 5 votes vote down vote up
@Override
public void handle (KeyEvent e)                     // onKeyTyped
{
  if (e.getEventType () != KeyEvent.KEY_TYPED)
    return;
  String c = e.getCharacter ();
  if (c.isEmpty ())
    return;
  char ch = c.charAt (0);

  if (screen.isKeyboardLocked () || e.isMetaDown () || e.isControlDown ()
      || e.isAltDown ())
  {
    // seems to be a bug in java
    if (e.isMetaDown ())
    {
      if (ch == '-')                    // osx fix
      {
        screen.getFontManager ().smaller ();
        e.consume ();
      }
      else if (ch == '=')               // osx fix
      {
        screen.getFontManager ().bigger ();
        e.consume ();
      }
    }

    return;
  }

  if (ch >= 32 && ch < 0x7F)
  {
    cursor.typeChar ((byte) Dm3270Utility.asc2ebc[ch]);
    e.consume ();
  }
}
 
Example 9
Source File: WSRecorder.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
public void recordRawKeyEvent(RFXComponent r, KeyEvent e) {
    JSONObject event = new JSONObject();
    event.put("type", "key_raw");
    KeyCode keyCode = e.getCode();
    if (keyCode.isModifierKey()) {
        return;
    }
    if ((keyCode.isFunctionKey() || keyCode.isArrowKey() || keyCode.isKeypadKey() || keyCode.isMediaKey()
            || keyCode.isNavigationKey() || e.isControlDown() || e.isMetaDown() || e.isAltDown()
            || needManualRecording(keyCode)) && e.getEventType() == KeyEvent.KEY_PRESSED) {
        String mtext = buildModifiersText(e);
        event.put("modifiersEx", mtext);
        KeysMap keysMap = KeysMap.findMap(e.getCode());
        if (keysMap == KeysMap.NULL) {
            return;
        }
        String keyText;
        if (keysMap == null) {
            keyText = e.getText();
        } else {
            keyText = keysMap.toString();
        }
        event.put("keyCode", keyText);
    } else if (e.getEventType() == KeyEvent.KEY_TYPED && !e.isControlDown() && !needManualRecording(keyCode)) {
        char[] cs = e.getCharacter().toCharArray();
        if (cs.length == 0) {
            return;
        }
        for (char c : cs) {
            if (Character.isISOControl(c) && hasMapping(c)) {
                event.put("keyChar", getMapping(c));
            } else {
                event.put("keyChar", "" + c);
            }
        }
    } else {
        return;
    }
    recordEvent(r, event);
}
 
Example 10
Source File: KeyMap.java    From FxDock with Apache License 2.0 4 votes vote down vote up
protected static KKey key(KeyEvent ev)
	{
		int flags = 0;
		KeyCode cd;
		String ch;
		
		if(ev.getEventType() == KeyEvent.KEY_PRESSED)
		{
			flags |= KEY_PRESSED;
			cd = ev.getCode();
			ch = null;
		}
		else if(ev.getEventType() == KeyEvent.KEY_RELEASED)
		{
			flags |= KEY_RELEASED;
			cd = ev.getCode();
			ch = null;
		}
		else if(ev.getEventType() == KeyEvent.KEY_TYPED)
		{
			flags |= KEY_TYPED;
			cd = null;
			ch = ev.getCharacter();
		}
		else
		{
			throw new Error("?" + ev.getEventType());
		}
		
		if(ev.isAltDown())
		{
			flags |= ALT;
		}
		
		if(ev.isControlDown())
		{
			flags |= CTRL;
		}

		if(ev.isMetaDown())
		{
			flags |= META;
		}

		if(ev.isShiftDown())
		{
			flags |= SHIFT;
		}
		
		if(ev.isShortcutDown())
		{
			flags |= ACTUAL_SHORTCUT;
		}
		
//		D.f("key event 0x%8x %s", flags, ev.getCode());
		
		return new KKey(flags, cd, ch);
	}
 
Example 11
Source File: AcceleratorsTests.java    From RichTextFX with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public AcceleratorsTestsHelper(EventTarget source, String character, KeyCode key, boolean controlDown, boolean altDown, boolean expected) {
	keyEvent = new KeyEvent(source, source, KeyEvent.KEY_TYPED, character, key.getName(), key,
			false, controlDown, altDown, false);
	expectedConsumeResult = expected;
}