Community
Participate
Working Groups
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(); } } } }
Move the mouse to select text in the browser so that display.getFocusControl properly returns the WebSite instance.
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.
As a workaround for 3.4.2, would it be safe to call WebSite.getParent().getParent() to add the key listener to the Browser?
> 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.
*** Bug 328691 has been marked as a duplicate of this bug. ***
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.
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.