Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Changing Behavior of Default Window Buttons
Changing Behavior of Default Window Buttons [message #464296] Mon, 21 November 2005 08:14 Go to next message
Jeff Yuan is currently offline Jeff YuanFriend
Messages: 34
Registered: July 2009
Member
Hi,
Is there a way to change the behavior of default window buttons? Like in
the shell, can I override the default behavior of the X (in windows) close
button, and instead make it perform some action (like display a
confirmation dialog box and prompt to save data) before closing?

If so, how?

Thanks.
Re: Changing Behavior of Default Window Buttons [message #464302 is a reply to message #464296] Mon, 21 November 2005 08:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: friederich.kupzog.de

Hi,

attach a sehllListener to your shell and listen for shellClosed event.
In the listener, set event.doit = false. Then you can execute your own
code and finally close the shell with shell.close().

Hope that helped,
Friederich

zinc wrote:
> Hi,
> Is there a way to change the behavior of default window buttons? Like
> in the shell, can I override the default behavior of the X (in windows)
> close button, and instead make it perform some action (like display a
> confirmation dialog box and prompt to save data) before closing?
>
> If so, how?
>
> Thanks.
>


--
Friederich Kupzog
Elektronik & Software
Neusser Str. 5-7
50670 Köln
Tel 0241 160696-1
Fax 0221 726670
www.kupzog.de/fkmk
Re: Changing Behavior of Default Window Buttons [message #464324 is a reply to message #464302] Mon, 21 November 2005 15:27 Go to previous messageGo to next message
Jeff Yuan is currently offline Jeff YuanFriend
Messages: 34
Registered: July 2009
Member
Thanks for the help.
Actually Problem... [message #464327 is a reply to message #464302] Mon, 21 November 2005 15:48 Go to previous messageGo to next message
Jeff Yuan is currently offline Jeff YuanFriend
Messages: 34
Registered: July 2009
Member
I do this:

shell.addShellListener(new ShellListener() {

public void shellClosed(ShellEvent event) {
event.doit = false;
System.out.println("TEst");
shell.close();
}
public void shellActivated(ShellEvent arg0) {}
public void shellDeactivated(ShellEvent arg0) {}
public void shellIconified(ShellEvent arg0) {}
public void shellDeiconified(ShellEvent arg0) {}

});

For example... And when I click the close button, the application hangs
and freezes.

Am I following your instruction incorrectly?
Re: Actually Problem... [message #464329 is a reply to message #464327] Mon, 21 November 2005 16:15 Go to previous messageGo to next message
Stefan Langer is currently offline Stefan LangerFriend
Messages: 236
Registered: July 2009
Senior Member
This causes an infinite loop since shell.close will reinform your
shelllistener.

You should add a flag to your listener that prevents it from reexecuting
if it has been executed.

Regards
Stefan

zinc wrote:
> I do this:
>
> shell.addShellListener(new ShellListener() {
>
> public void shellClosed(ShellEvent event) {
> event.doit = false;
> System.out.println("TEst");
> shell.close();
> }
> public void shellActivated(ShellEvent arg0) {}
> public void shellDeactivated(ShellEvent arg0) {}
> public void shellIconified(ShellEvent arg0) {}
> public void shellDeiconified(ShellEvent arg0) {}
>
> });
>
> For example... And when I click the close button, the application hangs
> and freezes.
>
> Am I following your instruction incorrectly?
>
Re: Actually Problem... [message #464370 is a reply to message #464329] Tue, 22 November 2005 09:16 Go to previous message
Eclipse UserFriend
Originally posted by: friederich.kupzog.de

Sorry Zinc for the bad suggestion with using shell.close() without any
additional flags....


Stefan Langer wrote:
> This causes an infinite loop since shell.close will reinform your
> shelllistener.
>
> You should add a flag to your listener that prevents it from reexecuting
> if it has been executed.


--
Friederich Kupzog
Elektronik & Software
Neusser Str. 5-7
50670 Köln
Tel 0241 160696-1
Fax 0221 726670
www.kupzog.de/fkmk
Previous Topic:How to send custom event to SWT widgets
Next Topic:doubts about draw2d
Goto Forum:
  


Current Time: Fri Aug 23 23:56:43 GMT 2019

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

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

Back to the top