Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Disable "Close Window" button on the title bar of a dialog
Disable "Close Window" button on the title bar of a dialog [message #528941] Thu, 22 April 2010 09:20 Go to next message
Kai Schlamp is currently offline Kai Schlamp
Messages: 344
Registered: July 2009
Senior Member
Hello.

I have to make a dialog (better to say a TitleAreaDialog) non-cancelable. The cancel button is easy to manage, but that little "Close Windows" button on the title bar not.
It even more a problem as it sends the same return code as cancel and so can't be fetched in the close method.

Regards,
Kai
Re: Disable "Close Window" button on the title bar of a dialog [message #528957 is a reply to message #528941] Thu, 22 April 2010 09:49 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

That close window button comes from the shell style (AFAIK), possibly
set in org.eclipse.jface.dialogs.Dialog.Dialog(IShellProvider)

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Disable "Close Window" button on the title bar of a dialog [message #528970 is a reply to message #528957] Thu, 22 April 2010 10:05 Go to previous messageGo to next message
Kai Schlamp is currently offline Kai Schlamp
Messages: 344
Registered: July 2009
Senior Member
Paul Webster wrote on Thu, 22 April 2010 09:49
That close window button comes from the shell style (AFAIK), possibly
set in org.eclipse.jface.dialogs.Dialog.Dialog(IShellProvider)



Thanks for the hint, Paul. But I still see no way to disable that close button.

I found the following example somewhere how to solve it, but it doesn't work (at least under Linux GTK):

getShell().addListener(SWT.Close, new Listener() {
@Override
public void handleEvent(Event event) {
event.doit = false;
}
});

Any suggestions?
Re: Disable "Close Window" button on the title bar of a dialog [message #528976 is a reply to message #528941] Thu, 22 April 2010 10:21 Go to previous messageGo to next message
Kai Schlamp is currently offline Kai Schlamp
Messages: 344
Registered: July 2009
Senior Member
It seems I have found a solution for TitleAreaDialog.

@Override
protected ShellListener getShellListener() {
return new ShellAdapter() {
public void shellClosed(ShellEvent event) {
event.doit = false; // don't close now
}
};
}
Re: Disable "Close Window" button on the title bar of a dialog [message #529237 is a reply to message #528970] Fri, 23 April 2010 10:26 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Kai Schlamp wrote:
> Thanks for the hint, Paul. But I still see no way to disable that close
> button.


In your constructor after you call super, set the shell style to
something that doesn't include the close button.


> I found the following example somewhere how to solve it, but it doesn't
> work (at least under Linux GTK):
>
> getShell().addListener(SWT.Close, new Listener() {
> @Override
> public void handleEvent(Event event) {
> event.doit = false;
> }
> });
>

As you found out, doit is used more by the typed listeners (like
ShellListener). For untyped listeners, the equivalent is:

event.type = SWT.None.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Disable "Close Window" button on the title bar of a dialog [message #529575 is a reply to message #528970] Mon, 26 April 2010 09:07 Go to previous message
Praveen  is currently offline Praveen
Messages: 86
Registered: July 2009
Member
Kai Schlamp wrote:
> I found the following example somewhere how to solve it, but it doesn't
> work (at least under Linux GTK):
>
> getShell().addListener(SWT.Close, new Listener() {
> @Override
> public void handleEvent(Event event) {
> event.doit = false;
> }
> });
I don't think that is right. The snippet works well on
Linux-GTK(Ubuntu9.04 in my case). Which version of GTK you are running ?
Also please make sure getShell() points to the dialog you are referring?
Previous Topic:\u0000 in strings behaviour intended?
Next Topic:browser and javascript
Goto Forum:
  


Current Time: Fri Aug 01 01:54:56 EDT 2014

Powered by FUDForum. Page generated in 0.07080 seconds