first, I really like CEF and JCEF it is exactly what I searched for.
I want to use JCEF for an application that is controlled by a touchscreen.
I want to include a virtual keyboard that can be used instead of the non existing physical keyboard.
I want that the keyboard is only displayed if it is needed. That means I need some way to listen for focus and unfocus events on input fields. Is this somehow possible. I couldn't find a way.
Another thing is that I want to send keyboard inputs from the virtual keyboard to the browser so I can write letters into the currently selected input field. I tried to do that testwise with a single button that sends a single letter to the browser. The problem is that everytime I click on the button the input field in the bowser loses focus. I used `setFocusable(false);` for the button, but that didn't help.
This is my code so far:
- Code: Select all
getContentPane().add(browerUI_, BorderLayout.CENTER);
Button button = new Button();
button.setLabel("Write letter");
button.setFocusable(false);
button.addActionListener((e) -> {
/*
KeyEvent keyEvent = new KeyEvent(button, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), 0, KeyEvent.VK_D, 'd');
KeyboardFocusManager.getCurrentKeyboardFocusManager().dispatchKeyEvent(keyEvent);
*/
try {
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_D);
robot.keyRelease(KeyEvent.VK_D);
} catch (AWTException ex) {
ex.printStackTrace();
}
});
getContentPane().add(button, BorderLayout.SOUTH);
pack();
setSize(800, 600);
getContentPane().requestFocusInWindow();
Thanks for your help