Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » KeyEvents are not triggered for Browser SWT.EDGE
KeyEvents are not triggered for Browser SWT.EDGE [message #1854824] Tue, 13 September 2022 10:55 Go to next message
Mokhtar Alshubei is currently offline Mokhtar AlshubeiFriend
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

Re: KeyEvents are not triggered for Browser SWT.EDGE [message #1854826 is a reply to message #1854824] Tue, 13 September 2022 13:32 Go to previous messageGo to next message
Mokhtar Alshubei is currently offline Mokhtar AlshubeiFriend
Messages: 121
Registered: November 2011
Location: Germany
Senior Member
Won't Fix!
Clearly due to
https://www.eclipse.org/swt/faq.php#:~:text=%2C%20MouseListener%3A-,Unsupported.%20Missing%20upstream%20API.,-evaluate(String%20script

The Edge Platform is not so far to support KeyListeners. So, I think there would be no possibility right now. Take another one; we will go ahead with SWT.IE
Re: KeyEvents are not triggered for Browser SWT.EDGE [message #1854972 is a reply to message #1854826] Wed, 21 September 2022 06:26 Go to previous messageGo to next message
Martin J is currently offline Martin JFriend
Messages: 50
Registered: August 2015
Member
Notice that IE will be removed completed in 2027!
Re: KeyEvents are not triggered for Browser SWT.EDGE [message #1854973 is a reply to message #1854972] Wed, 21 September 2022 06:45 Go to previous message
Martin J is currently offline Martin JFriend
Messages: 50
Registered: August 2015
Member
LocationListener is also not supported by Edge implementation. This is a big problem for me. I rely on LocationListener to provide help instructions stored in jar files.
Previous Topic:Failed to unregister class Chrome_WidgetWin_0. Error = 0
Next Topic:Edge browser LocationListener links are blocked
Goto Forum:
  


Current Time: Wed Nov 06 11:53:28 GMT 2024

Powered by FUDForum. Page generated in 0.03776 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top