Project: SWT
Bug 180615 too many paint events have been sent out when key down in Canvas
Reported: 2007-04-03 01:09:01 | Status: verified fixed

Build ID: I20070306-1200 Steps To Reproduce: 1. Write a simple example using Canvas 2. Listen to key down and paint event 3. Holding down the arrow down key, you will find too many paint events have been sent out, key down event and paint event are alternate. 4. If you run this in build I20070222-0951, it only sends out key down event, which is correct. 5. I have tried this in 3.2, it only sends out key down event too. 6. Too many paint events have blocked UI main thread, so that it can not get time to do other UI job. More information: Code to test: import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; public class TestPaint { public static void main(String [] args){ Display display = new Display(); Shell shell = new Shell(display, SWT.SHELL_TRIM | SWT.V_SCROLL); Listener listener = new Listener() { public void handleEvent(Event e) { switch (e.type) { case SWT.Paint: System.out.println(" paint event"); break; case SWT.KeyDown: System.out.println(" key down event"); break; } } }; shell.addListener(SWT.Paint, listener); shell.addListener(SWT.KeyDown, listener); shell.pack(); shell.open(); while(!shell.isDisposed()){ if(!display.readAndDispatch()) display.sleep(); } display.dispose(); } }

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java