Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » SWT Browser Control loosing focus on Enter key press(SWT Browser Control loosing focus on Enter key press)
SWT Browser Control loosing focus on Enter key press [message #506946] Mon, 11 January 2010 08:27 Go to next message
Nitesh Agrawal is currently offline Nitesh AgrawalFriend
Messages: 4
Registered: January 2010
Junior Member
Hello Experts,

I have created a Rich text editor using a SWT browser control.
The Editor is woring perfectly fine when run as an independent
application.
Now, I have a RCP application, in which I have a mulipage editor,
this multipage editor has a SWT Section control.
I am placing my Rich Text editor inside this Section.
Now, when I write some thing on the first line and press 'Enter'
the focus is getting lost from the Rich text editor. I have observer that on pressing enter, the focus is getting lost from multipage editor itself.
I have tried a couple of this till now to handle this situation, like handling the Enter press key explicitly, but with no success.

any suggestions on why it works in a stand alone mode but loses focus when embedding inside a section.

Thanks and regards,
Nitesh
Re: SWT Browser Control loosing focus on Enter key press [message #507473 is a reply to message #506946] Wed, 13 January 2010 15:33 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi Nitesh,

I would guess that one of the following has changed when you run in the
context of an RCP app:
- a default button is now present in the parent Shell, which takes focus
when Enter is pressed
- an accelerator is defined that is being triggered (an accelerator of
'Enter' does not seem too likely)

I tried to make a case of a default button stealing focus when pressing
Enter in a Browser but could not. I tried a page with a <textarea>, and I
tried google, and in both cases pressing Enter did not send focus to my
default button (perhaps it should have). Anyways, you can prove/disprove
the default button theory by adding a display filter like:

display.addFilter(SWT.FocusIn, new Listener() {
public void handleEvent(Event event) {
Control focusControl = display.getFocusControl();
boolean isDefaultButton = shell.getDefaultButton() == focusControl;
System.out.println("new focus control: " + focusControl + " is
default button: " + isDefaultButton);
}
});

Also, which platform and swt version are you using?

Grant


"Nitesh" <niteshsince1982@gmail.com> wrote in message
news:hif90e$no7$1@build.eclipse.org...
> Hello Experts,
>
> I have created a Rich text editor using a SWT browser control.
> The Editor is woring perfectly fine when run as an independent
> application.
> Now, I have a RCP application, in which I have a mulipage editor,
> this multipage editor has a SWT Section control.
> I am placing my Rich Text editor inside this Section.
> Now, when I write some thing on the first line and press 'Enter'
> the focus is getting lost from the Rich text editor. I have observer that
on pressing enter, the focus is getting lost from multipage editor itself.
> I have tried a couple of this till now to handle this situation, like
handling the Enter press key explicitly, but with no success.
>
> any suggestions on why it works in a stand alone mode but loses focus when
embedding inside a section.
>
> Thanks and regards,
> Nitesh
Re: SWT Browser Control loosing focus on Enter key press [message #507902 is a reply to message #506946] Fri, 15 January 2010 04:57 Go to previous message
Nitesh Agrawal is currently offline Nitesh AgrawalFriend
Messages: 4
Registered: January 2010
Junior Member
Hi Grant,

Thanks a lot for the reply.
As you mentioned correctly, I found out that there was a default button in my parent shell(in some view), which was taking focus when I press ENTER.
I have refactored my code and made changes accordingly and Enter is now working in my Rich text editor.

I am using Windows vista and SWT version 3.5.0

Thanks again for your help.

Best Regards,
Nitesh
Previous Topic:Listen to table item changes
Next Topic:Can't load unknown source libswt-win32-3617.so
Goto Forum:
  


Current Time: Fri Jul 10 13:01:32 GMT 2020

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

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

Back to the top