Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Display.setFocusControl in RAP
Display.setFocusControl in RAP [message #816875] Fri, 09 March 2012 11:23 Go to next message
Amandeep Chahal is currently offline Amandeep ChahalFriend
Messages: 85
Registered: September 2011
Location: India
Member
Hi,
I have a requirement where I dispose the control when it is not in focus. However, due to the implementation in of Display.setFocusControl this is leading to a WIDGET DISPOSED error.


FocusEvent event = new FocusEvent( currentFocusControl, FocusEvent.FOCUS_LOST );
event.processEvent();
currentFocusControl.getShell().updateDefaultButton( currentFocusControl, false);


In 'event.processEvent' my FOcusLost event disposes the control and 'currentFocusControl.getShell()' throws a WIDGET DISPOSED error.

Is there a way to fix this? Or avoid this?
Re: Display.setFocusControl in RAP [message #816891 is a reply to message #816875] Fri, 09 March 2012 11:41 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi,
I think that your use case (dispose a control in a focus lost event) is
a valid one and works fine in SWT. Please file a bugzilla and we will
have a look on it a s soon as possible.
Best,
Ivan

On 3/9/2012 1:23 PM, Amandeep Chahal wrote:
> Hi,
> I have a requirement where I dispose the control when it is not in
> focus. However, due to the implementation in of
> Display.setFocusControl this is leading to a WIDGET DISPOSED error.
>
> FocusEvent event = new FocusEvent( currentFocusControl,
> FocusEvent.FOCUS_LOST );
> event.processEvent();
> currentFocusControl.getShell().updateDefaultButton(
> currentFocusControl, false);
>
>
> In 'event.processEvent' my FOcusLost event disposes the control and
> 'currentFocusControl.getShell()' throws a WIDGET DISPOSED error.
>
> Is there a way to fix this? Or avoid this?

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Display.setFocusControl in RAP [message #816912 is a reply to message #816891] Fri, 09 March 2012 12:17 Go to previous messageGo to next message
Amandeep Chahal is currently offline Amandeep ChahalFriend
Messages: 85
Registered: September 2011
Location: India
Member
Hi Ivan,
Thanks for your reply.
Submitted bug : https://bugs.eclipse.org/bugs/show_bug.cgi?id=373770
Re: Display.setFocusControl in RAP [message #816916 is a reply to message #816891] Fri, 09 March 2012 12:17 Go to previous messageGo to next message
Amandeep Chahal is currently offline Amandeep ChahalFriend
Messages: 85
Registered: September 2011
Location: India
Member
Hi Ivan,
Thanks for your reply.
Submitted bug : https://bugs.eclipse.org/bugs/show_bug.cgi?id=373770
Re: Display.setFocusControl in RAP [message #817012 is a reply to message #816916] Fri, 09 March 2012 14:31 Go to previous messageGo to next message
Cole Markham is currently offline Cole MarkhamFriend
Messages: 150
Registered: July 2009
Location: College Station, TX
Senior Member

As a workaround, you can probably use display.asyncExec from the focus listener to dispose the control. That should let the focus event finish processing before the control gets disposed.

Control control;
...
public void focusLost(FocusEvent event) {
  control.getDisplay().asyncExec(new Runnable(){
    // make sure something else didn't dispose it
    if (control != null && !control.isDisposed()){
      control.dispose();
    }
  });
}
Re: Display.setFocusControl in RAP [message #817017 is a reply to message #816916] Fri, 09 March 2012 14:31 Go to previous messageGo to next message
Cole Markham is currently offline Cole MarkhamFriend
Messages: 150
Registered: July 2009
Location: College Station, TX
Senior Member

As a workaround, you can probably use display.asyncExec from the focus listener to dispose the control. That should let the focus event finish processing before the control gets disposed.


Control control;
...
public void focusLost(FocusEvent event) {
control.getDisplay().asyncExec(new Runnable(){
// make sure something else didn't dispose it
if (control != null && !control.isDisposed()){
control.dispose();
}
});
}
Re: Display.setFocusControl in RAP [message #817059 is a reply to message #816916] Fri, 09 March 2012 15:26 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Thanks for the bug report. It is fixed in CVS HEAD and will be part of
1.5M6.
Best,
Ivan

On 3/9/2012 2:17 PM, Amandeep Chahal wrote:
> Hi Ivan, Thanks for your reply. Submitted bug :
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=373770

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Display.setFocusControl in RAP [message #818815 is a reply to message #817059] Mon, 12 March 2012 06:26 Go to previous message
Amandeep Chahal is currently offline Amandeep ChahalFriend
Messages: 85
Registered: September 2011
Location: India
Member
Thanks.

Regards,
Aman.
Re: Display.setFocusControl in RAP [message #818819 is a reply to message #817059] Mon, 12 March 2012 06:26 Go to previous message
Amandeep Chahal is currently offline Amandeep ChahalFriend
Messages: 85
Registered: September 2011
Location: India
Member
Thanks.

Regards,
Aman.
Previous Topic:Display.setFocusControl in RAP
Next Topic:JDBC Connection Pool
Goto Forum:
  


Current Time: Tue Apr 16 15:19:19 GMT 2024

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

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

Back to the top