Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Using a browser widget inside a Wizard
Using a browser widget inside a Wizard [message #647266] Wed, 05 January 2011 13:28 Go to next message
Roel De Nijs is currently offline Roel De NijsFriend
Messages: 28
Registered: March 2010
Junior Member
Hi

First a little introduction: I have a wizard and one of its pages contains a SWT Browser widget. The browser loads a web page which contains a HTML form. This form contains a input field of type textarea.

Now the actual problem: when the user is typing text in this textarea and wants a new line he presses Enter-key, but then the default button of the wizard dialog is invoked (instead of inserting a new line inside the textarea).

To avoid this behavior I set the default button to null, which gives me the desired result: the default button is not invoked and a new line is inserted in the textarea.

Is this the intended behavior for the browser widget?

I also tried adding a KeyListener to the browser widget to see if it was possible to intercept the different key strokes, but none of the methods (keyPressed and keyReleased) are invoked when you press a key when the browser has the focus.

Kind regards,
Roel
Re: Using a browser widget inside a Wizard [message #647307 is a reply to message #647266] Wed, 05 January 2011 15:47 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi Roel,

Pressing Enter should stay within the Browser by default. It will cause a
Traverse event to be sent whose doit field is set to false, and only by
changing this doit to true should the default button be invoked.

I've tried a small example of this and it's working for me as expected. Are
you using an old Eclipse version (I tried 3.5.2 and the 3.7 stream)? Which
platform? And presumably your Browser is created with style SWT.NONE? My
case was to setUrl() to a local file containing:
"
<html>
<body>
<textarea rows="2" cols="20">
asdf
</textarea>
</body>
</html>
"

Grant


"Roel De Nijs" <roel@javaroe.be> wrote in message
news:ig1rcq$j27$1@news.eclipse.org...
> Hi
>
> First a little introduction: I have a wizard and one of its pages contains
> a SWT Browser widget. The browser loads a web page which contains a HTML
> form. This form contains a input field of type textarea.
>
> Now the actual problem: when the user is typing text in this textarea and
> wants a new line he presses Enter-key, but then the default button of the
> wizard dialog is invoked (instead of inserting a new line inside the
> textarea).
>
> To avoid this behavior I set the default button to null, which gives me
> the desired result: the default button is not invoked and a new line is
> inserted in the textarea.
>
> Is this the intended behavior for the browser widget?
>
> I also tried adding a KeyListener to the browser widget to see if it was
> possible to intercept the different key strokes, but none of the methods
> (keyPressed and keyReleased) are invoked when you press a key when the
> browser has the focus.
>
> Kind regards,
> Roel
Re: Using a browser widget inside a Wizard [message #647343 is a reply to message #647266] Wed, 05 January 2011 17:29 Go to previous messageGo to next message
Roel De Nijs is currently offline Roel De NijsFriend
Messages: 28
Registered: March 2010
Junior Member
Hi Grant,

We are using a slightly older version: 3.5.1.R35x_v20090910 and we work in a Windows XP environment.

The browser widget is indeed created with style SWT.NONE.

Kind regards,
Roel
Re: Using a browser widget inside a Wizard [message #647480 is a reply to message #647343] Thu, 06 January 2011 15:20 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
This should still work in 3.5.1. Can you run the snippet below and see
which behaviour happens for you? And if it works (meaning that the Enter is
kept within the Browser), then can you change the snippet's
browser.setText(...) line to either setText() or setUrl() to instead display
your content, and see if it still gives the Enter key to the default button
instead of keeping it within the Browser?

public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
shell.setLayout(new GridLayout());
new Text(shell, SWT.SINGLE);
Browser browser = new Browser(shell, SWT.NONE);
browser.setText("<html><body><textarea rows=\"2\"
cols=\"20\">asdf</textarea></body></html>");
browser.setLayoutData(new GridData(300,200));
Button cancel = new Button (shell, SWT.PUSH);
cancel.setText ("Cancel");
cancel.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
System.out.println("Cancel");
}
});
shell.setDefaultButton (cancel);
shell.pack ();
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}

Grant


"Roel De Nijs" <roel@javaroe.be> wrote in message
news:ig29fp$d0j$1@news.eclipse.org...
> Hi Grant,
>
> We are using a slightly older version: 3.5.1.R35x_v20090910 and we work in
> a Windows XP environment.
>
> The browser widget is indeed created with style SWT.NONE.
>
> Kind regards,
> Roel
Re: Using a browser widget inside a Wizard [message #647485 is a reply to message #647480] Thu, 06 January 2011 15:55 Go to previous messageGo to next message
Roel De Nijs is currently offline Roel De NijsFriend
Messages: 28
Registered: March 2010
Junior Member
When I used your snippet with the setText-method a new line was inserted when pressing the Enter key.
When I used my url which directs to a webpage which uses TinyMCE to improve the textarea's capabilities and allow inserting styled text, the default button is activated (and 'Cancel' is printed to console) when pressing the Enter key.

I'll share the link we use in the browser widget: [url removed] and just click on the text to go to editing mode and show the textarea.

[edit] I removed the url, because it's not meant for public use, it was just for showing the issue

[Updated on: Fri, 07 January 2011 15:58]

Report message to a moderator

Re: Using a browser widget inside a Wizard [message #647645 is a reply to message #647485] Fri, 07 January 2011 14:51 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Ok, I see it with your link. This is fixed in eclipse/swt 3.6 and newer, I
assume as a result of the fix for
https://bugs.eclipse.org/bugs/show_bug.cgi?id=231311 . The changes for IE
were not trivial, so I don't have a workaround to suggest that would make
this work in 3.5.1.

Grant


"Roel De Nijs" <roel@javaroe.be> wrote in message
news:ig4ob5$hco$1@news.eclipse.org...
> When I used your snippet with the setText-method a new line was inserted
> when pressing the Enter key.
> When I used my url which directs to a webpage which uses TinyMCE to
> improve the textarea's capabilities and allow inserting styled text, the
> default button is activated (and 'Cancel' is printed to console) when
> pressing the Enter key.
>
> I'll share the link we use in the browser widget:
> http://www.eproof.be/app/index.php?mod=edit&send_id=820e 52b2e9f90ddb0cae86deaabbac4f&mail=1282&token=ed02a50 64516ba685f748442e6d0f281
> and just click on the text to go to editing mode and show the textarea.
>
Re: Using a browser widget inside a Wizard [message #647657 is a reply to message #647645] Fri, 07 January 2011 16:01 Go to previous message
Roel De Nijs is currently offline Roel De NijsFriend
Messages: 28
Registered: March 2010
Junior Member
Hi Grant,

Thanks for verifying this issue. I found myself a work-around (disabling the default button for that specific wizard page), so we'll stick to that one until we upgrade to version 3.6.

Kind regards,
Roel
Previous Topic:RCP Color Palette
Next Topic:Synchronize product definition to plugin.xml in headless build?
Goto Forum:
  


Current Time: Fri Apr 26 10:27:53 GMT 2024

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

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

Back to the top