The naive solution is to add a SWT.Paint
event listener to the Canvas
, as that can run into problems as we don't know the sequence of calls to listeners (have a look at EventTable.hook()
which will reuse an old slot in the listener table before adding to the end of the table...). Thus the original listener might run before or after your listener.
A better solution - which I have not tried, but believe to work - whould be to add a new Composite
on top of the original Canvas
and then add your listener to this widget, as any Paint
listener of the new Composite
is guaranteed to run after all listeners on the Canvas
itself. Remember to
- add a
Size
listener to the Canvas
to make sure the size of the Composite
is always correct
- use
setBackgroundMode(SWT.INHERIT_FORCE)
on the Canvas