Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » how to cancel event
how to cancel event [message #436319] Mon, 17 May 2004 14:34 Go to next message
Eclipse UserFriend
Originally posted by: thomas.hollfelder.hpigmbh.com

I have a form with a tree where user can maniplate data. I want
synchronize data with a db on closing the tree therefore I've added a
Listener to the tree
this.addListener(SWT.CLOSE,new Listener(){

public void handleEvent(Event ev) {
System.out.println("event Listen on close");
if (m_dirty){
MessageBox box=new
MessageBox(getShell(),SWT.APPLICATION_MODAL|SWT.YES|SWT.NO|S WT.CANCEL);
box.setText("Frage?");
box.setMessage("Wollen Sie die Daten Speichern");
int result=box.open();
System.out.println("Antwort=" + result + ", result!=SWT.CANCEL="+
(result!=SWT.CANCEL));
ev.doit=(result!=SWT.CANCEL);
}

}});

this doesn't work for a dispose event and if I change Listener to a
SWT.Dispose event my code runs but setting the ev.doit does not work.

So my question is how to cancel such a event and is there a better event
to listen for than dispose or close?

Thanks,
Thomas
Re: how to cancel event [message #436398 is a reply to message #436319] Tue, 18 May 2004 16:46 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
Use SWT.Close on the Shell, not the Tree.

"ThomasHollfelder" <thomas.hollfelder@hpigmbh.com> wrote in message
news:c8aiii$91a$1@eclipse.org...
> I have a form with a tree where user can maniplate data. I want
> synchronize data with a db on closing the tree therefore I've added a
> Listener to the tree
> this.addListener(SWT.CLOSE,new Listener(){
>
> public void handleEvent(Event ev) {
> System.out.println("event Listen on close");
> if (m_dirty){
> MessageBox box=new
> MessageBox(getShell(),SWT.APPLICATION_MODAL|SWT.YES|SWT.NO|S WT.CANCEL);
> box.setText("Frage?");
> box.setMessage("Wollen Sie die Daten Speichern");
> int result=box.open();
> System.out.println("Antwort=" + result + ", result!=SWT.CANCEL="+
> (result!=SWT.CANCEL));
> ev.doit=(result!=SWT.CANCEL);
> }
>
> }});
>
> this doesn't work for a dispose event and if I change Listener to a
> SWT.Dispose event my code runs but setting the ev.doit does not work.
>
> So my question is how to cancel such a event and is there a better event
> to listen for than dispose or close?
>
> Thanks,
> Thomas
>
>
Re: how to cancel event [message #436399 is a reply to message #436398] Tue, 18 May 2004 16:49 Go to previous message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
I was pasting in the snippet but the mouse got away from me ...

http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/plat form-swt-home/snippits/snippet99.html

"Steve Northover" <steve_northover@ca.ibm.com> wrote in message
news:c8de7j$qki$1@eclipse.org...
> Use SWT.Close on the Shell, not the Tree.
>
> "ThomasHollfelder" <thomas.hollfelder@hpigmbh.com> wrote in message
> news:c8aiii$91a$1@eclipse.org...
> > I have a form with a tree where user can maniplate data. I want
> > synchronize data with a db on closing the tree therefore I've added a
> > Listener to the tree
> > this.addListener(SWT.CLOSE,new Listener(){
> >
> > public void handleEvent(Event ev) {
> > System.out.println("event Listen on close");
> > if (m_dirty){
> > MessageBox box=new
> > MessageBox(getShell(),SWT.APPLICATION_MODAL|SWT.YES|SWT.NO|S WT.CANCEL);
> > box.setText("Frage?");
> > box.setMessage("Wollen Sie die Daten Speichern");
> > int result=box.open();
> > System.out.println("Antwort=" + result + ", result!=SWT.CANCEL="+
> > (result!=SWT.CANCEL));
> > ev.doit=(result!=SWT.CANCEL);
> > }
> >
> > }});
> >
> > this doesn't work for a dispose event and if I change Listener to a
> > SWT.Dispose event my code runs but setting the ev.doit does not work.
> >
> > So my question is how to cancel such a event and is there a better event
> > to listen for than dispose or close?
> >
> > Thanks,
> > Thomas
> >
> >
>
>
Previous Topic:ActiveX on PocketPC
Next Topic:catch event
Goto Forum:
  


Current Time: Tue Apr 16 23:06:07 GMT 2024

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

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

Back to the top