KeyEvents are not triggered for Browser SWT.EDGE [message #1854824] |
Tue, 13 September 2022 10:55 |
Mokhtar Alshubei Messages: 121 Registered: November 2011 Location: Germany |
Senior Member |
|
|
Hi,
as in the reproducer below, the keylisteners of the swt browser widget are not working when I choose "Edge" as platform renderer. Our project is an RCP4 client but the same issue I could reproduce anyway in one java class. So, what is the solution you think to make the browser recognize the key events?
This behavior makes the shortcuts e.g. alt+f for file menu not working, too. Seems like these keyups are cancelled because of the browser (edge) control.
The same code below, once I choose SWT.CHROMIUM or WEBKIT will work and print out the keys you are pressing.
Thank you for any help!
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.*;
public class SWTBrowserExample {
private Shell shell;
public SWTBrowserExample() {
shell = new Shell(Display.getDefault());
shell.setLayout(new FillLayout());
Browser browser = new Browser(shell, SWT.EDGE);
browser.setText("any thing or maybe <input type='text'/>");
browser.addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {
System.out.println("Key pressed: " + e);
}
});
shell.setSize(800, 600);
}
public static void main(String[] args) {
SWTBrowserExample rssBrowser = new SWTBrowserExample();
rssBrowser.shell.setVisible(true);
Display display = Display.getDefault();
while (!rssBrowser.shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
[Updated on: Tue, 13 September 2022 10:56] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03776 seconds