Community
Participate
Working Groups
Build Identifier: 1.3.0.20100615-1704 There's a problem in UntypedEventAdapter, in some cases the state of event.doit is not being translated to so called Typed? Event (ex: Event -> [Shell]Event). This problem make impossible to protect: - the user against closing the window by mistake (when unsaved data present etc), - the user against entering unwanted characters in the input box (VerifyEvent). My quick solution is to apply the following patch: diff -u UntypedEventAdapter.java.org UntypedEventAdapter.java --- UntypedEventAdapter.java.org 2010-09-20 22:29:04.000000000 +0200 +++ UntypedEventAdapter.java 2010-09-20 22:29:07.000000000 +0200 @@ -86,6 +86,7 @@ Event event = createEvent( SWT.Selection, evt.getSource() ); copyFields( evt, event ); dispatchEvent( event ); + evt.doit = event.doit; } public void focusGained( final FocusEvent evt ) { @@ -122,12 +123,14 @@ Event event = createEvent( SWT.Close, evt.getSource() ); copyFields( evt, event ); dispatchEvent( event ); + evt.doit = event.doit; } public void shellDeactivated( final ShellEvent evt ) { Event event = createEvent( SWT.Deactivate, evt.getSource() ); copyFields( evt, event ); dispatchEvent( event ); + evt.doit = event.doit; } public void menuHidden( final MenuEvent evt ) { @@ -152,6 +155,7 @@ Event event = createEvent( SWT.Verify, evt.getSource() ); copyFields( evt, event ); dispatchEvent( event ); + evt.doit = event.doit; } public void update( final SetDataEvent evt ) { Reproducible: Always Steps to Reproduce: 1. Add the event handler to protect against closing the Shell 2. Try to close the shell via UI 3. SWT.Deactivate event is sent, set event.doit to false value 4. The shell is being close. The state of event.doit is lost, it is not being translated to ShellEvent. I can see lots of places in UntypedEventAdapter where the state of event is not being translated back to *Event. Quick fix attached in Details.
The event system has been rewritten (see bug bug 334028). UntypedEventAdapter is gone and all flags are copied from untyped to typed events in the same way as in SWT.