[racket-dev] while resizing drawing into a canvas is off

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Oct 18 11:10:53 EDT 2011

At Tue, 18 Oct 2011 16:32:54 +0200, Marijn wrote:
> the attached program draws a grid in a canvas and paints a few of the
> cells so created. When resizing the window, the grid is also dynamically
> resized together with the coloring of a few painted cells. Everything
> seems to work fine, except that while the window is being changed in
> size the drawing is off and the colored cells do not properly correspond
> to the drawn grid. You can see this especially well if you hold down the
> mouse button after resizing. When releasing it the grid lines will
> change position to match up once more with the colorings.

This was due to an internal inconsistency with `get-char-width' and
`get-char-height'. I've pushed a repair.

Beware that, under Windows, `on-paint' is called before `on-size',
which means that the state update in your `on-size' callback happens
too late. I think it would be nicer if `on-size' reliably came before
`on-paint' but it's difficult to maintain those kinds of guarantees
across all platforms. One solution is to add a call to `refresh' in
your `on-size' callback.

Posted on the dev mailing list.