Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Parent container of SWT Browser on XULRunner 10.0.2 is handling Enter and Escape key presses(For example, when I press the enter key in a browser page text field, the key press goes to my parent dialog, resulting in Dialog::okPressed())
Parent container of SWT Browser on XULRunner 10.0.2 is handling Enter and Escape key presses [message #946506] |
Tue, 16 October 2012 08:51 |
Stella Lok Messages: 10 Registered: September 2012 |
Junior Member |
|
|
Hi,
I discovered a major difference in behaviour between using the SWT Browser with XULRunner 10.0.2 and XULRunner 3.6.x, encountered on Windows XP 32-bit.
When I use an SWT Browser widget in a Dialog, with XULRunner 10.0.2, the "Enter" and "Escape" key press events are still handled by the parent container (i.e. the Dialog), even though the focus is on the SWT Browser widget. For example, when I press "Enter" in a browser page text field, the parent container will handle it, resulting in Dialog::okPressed() and subsequently Dialog::close(). Likewise, when I press the "Escape" key in a browser page text field, Dialog::close() will be triggered.
Is this a bug? I do not encounter this in XULRunner 3.6.x, nor in an SWT Browser using Internet Explorer.
Here is my test code, that can reproduce this behaviour when run in XULRunner 10.0.2, when "Enter" is pressed in the browser page text field:
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
public class TestDialog extends Dialog {
@Override
public boolean close() {
System.out.println("close()");
return super.close();
}
@Override
protected void okPressed() {
System.out.println("ok pressed");
super.okPressed();
}
public static void main(String args[]) {
Display display = Display.getDefault();
Shell shell = new Shell();
TestDialog d = new TestDialog(shell);
d.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
public TestDialog(Shell parentShell) {
super(parentShell);
}
@Override
protected Control createDialogArea(Composite parent) {
Display.DEBUG = true;
Composite container = (Composite) super.createDialogArea(parent);
container.setLayout(new GridLayout(1, false));
Composite composite = new Composite(container, SWT.NONE);
composite.setLayout(new GridLayout(1, false));
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1,
1));
Browser mozBrowser = new Browser(composite, SWT.MOZILLA);
mozBrowser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true,
1, 1));
mozBrowser.setUrl("google.com");
return container;
}
@Override
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
true);
createButton(parent, IDialogConstants.CANCEL_ID,
IDialogConstants.CANCEL_LABEL, false);
}
@Override
protected Point getInitialSize() {
return new Point(801, 582);
}
}
|
|
|
Re: Parent container of SWT Browser on XULRunner 10.0.2 is handling Enter and Escape key presses [message #950325 is a reply to message #946506] |
Fri, 19 October 2012 20:25 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
This looks like a bug introduced by a change in XULRunner 10. I've
logged https://bugs.eclipse.org/bugs/show_bug.cgi?id=392488 .
Grant
On 10/16/2012 4:51 AM, Stella Lok wrote:
> Hi,
>
> I discovered a major difference in behaviour between using the SWT
> Browser with XULRunner 10.0.2 and XULRunner 3.6.x, encountered on
> Windows XP 32-bit.
>
> When I use an SWT Browser widget in a Dialog, with XULRunner 10.0.2, the
> "Enter" and "Escape" key press events are still handled by the parent
> container (i.e. the Dialog), even though the focus is on the SWT Browser
> widget. For example, when I press "Enter" in a browser page text field,
> the parent container will handle it, resulting in Dialog::okPressed()
> and subsequently Dialog::close(). Likewise, when I press the "Escape"
> key in a browser page text field, Dialog::close() will be triggered.
>
> Is this a bug? I do not encounter this in XULRunner 3.6.x, nor in an SWT
> Browser using Internet Explorer.
>
> Here is my test code, that can reproduce this behaviour when run in
> XULRunner 10.0.2, when "Enter" is pressed in the browser page text field:
>
>
>
> import org.eclipse.jface.dialogs.Dialog;
> import org.eclipse.jface.dialogs.IDialogConstants;
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.browser.*;
> import org.eclipse.swt.graphics.*;
> import org.eclipse.swt.layout.*;
> import org.eclipse.swt.widgets.*;
> public class TestDialog extends Dialog {
>
> @Override
> public boolean close() {
> System.out.println("close()");
> return super.close();
> }
>
> @Override
> protected void okPressed() {
> System.out.println("ok pressed");
> super.okPressed();
> }
>
> public static void main(String args[]) {
> Display display = Display.getDefault();
> Shell shell = new Shell();
> TestDialog d = new TestDialog(shell);
> d.open();
>
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch()) {
> display.sleep();
> }
> }
> display.dispose();
>
> }
>
> public TestDialog(Shell parentShell) {
> super(parentShell);
> }
>
> @Override
> protected Control createDialogArea(Composite parent) {
> Display.DEBUG = true;
> Composite container = (Composite) super.createDialogArea(parent);
> container.setLayout(new GridLayout(1, false));
>
> Composite composite = new Composite(container, SWT.NONE);
> composite.setLayout(new GridLayout(1, false));
> composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
> true, 1,
> 1));
>
> Browser mozBrowser = new Browser(composite, SWT.MOZILLA);
> mozBrowser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
> true,
> 1, 1));
> mozBrowser.setUrl("google.com");
> return container;
> }
>
> @Override
> protected void createButtonsForButtonBar(Composite parent) {
> createButton(parent, IDialogConstants.OK_ID,
> IDialogConstants.OK_LABEL,
> true);
> createButton(parent, IDialogConstants.CANCEL_ID,
> IDialogConstants.CANCEL_LABEL, false);
> }
>
> @Override
> protected Point getInitialSize() {
> return new Point(801, 582);
> }
> }
>
|
|
| | | |
Goto Forum:
Current Time: Thu Apr 18 06:46:49 GMT 2024
Powered by FUDForum. Page generated in 0.02922 seconds
|