Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 269733 - Regression: Key listener not functional on WebSite anymore
Summary: Regression: Key listener not functional on WebSite anymore
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.4.2   Edit
Hardware: PC Windows Vista
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Grant Gayed CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-23 15:19 EDT by Benjamin Pasero CLA
Modified: 2021-12-01 19:25 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Pasero CLA 2009-03-23 15:19:55 EDT
Eclipse 3.4.2 or 3.5 M6
IE 8.0 final

See snippet below. The result for me is that the key listener is not called when I press the F2 key on 3.4 and 3.5. This worked in 3.3.

See this snippet:
public class Main {
	public static void main(String[] args) {
		final Display display = new Display();
		Shell shell = new Shell(display);
		shell.setLayout(new FillLayout());

		Button button = new Button(shell, SWT.PUSH);
		button.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false,
				false));
		button.setText("hi");
		button.setFocus();

		final Browser browser = new Browser(shell, SWT.NONE);
		browser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
		browser.setText("Hello Word");

		display.timerExec(2000, new Runnable() {
			@Override
			public void run() {
				Control focusControl = display.getFocusControl();
				System.out.println(focusControl);
				focusControl.addKeyListener(new KeyAdapter() {
					@Override
					public void keyPressed(KeyEvent e) {
						System.out.println(e);
					}
				});
			}
		});

		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}
}
Comment 1 Benjamin Pasero CLA 2009-03-23 15:20:35 EDT
Move the mouse to select text in the browser so that display.getFocusControl properly returns the WebSite instance.
Comment 2 Benjamin Pasero CLA 2009-03-23 15:22:14 EDT
This seems to work fine when adding a key listener to Browser, however our environment requires us to set a key listener to the focus control. Alternatively, getFocusControl should really return the Browser instead of WebSite because otherwise one has to use internal OS dependent class-instances to check if the Browser is the focus control or not.
Comment 3 Benjamin Pasero CLA 2009-03-24 01:09:31 EDT
As a workaround for 3.4.2, would it be safe to call WebSite.getParent().getParent() to add the key listener to the Browser?
Comment 4 Grant Gayed CLA 2009-03-24 10:27:47 EDT
> safe to call WebSite.getParent().getParent()

Yes this should be fine, there are a few places in WebSite where this is done.

I think the best fix would be for getFocusControl() to answer the Browser, to be consistent with other platforms.  Will talk to SSQ or SN about this.
Comment 5 Dani Megert CLA 2010-10-26 08:25:15 EDT
*** Bug 328691 has been marked as a duplicate of this bug. ***
Comment 6 Eclipse Webmaster CLA 2019-09-06 16:07:49 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.
Comment 7 Eclipse Genie CLA 2021-12-01 19:25:59 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.