[racket] Interactive Canvas

From: David Vanderson (david.vanderson at gmail.com)
Date: Mon Apr 9 17:18:24 EDT 2012

Not a dumb question at all.  Hopefully more experienced minds can give a 
smarter answer, but one way is to have your rectangles be separate from 

So you could store your rectangles in a regular old data structure.  
Write code to render that to a canvas as needed.  When a mouse event 
happens on the canvas, query the data structure to find which rectangle 
the event happened in.

I'm not very familiar with Racket's capabilities in this area, but I 
would start with the docs on region%

They can be scaled and rotated, and the in-region? function should let 
you figure out which region% a mouse event happened in.

Does that make sense?


On 04/09/2012 01:20 PM, Nick Shelley wrote:
> I don't have much gui programming experience, so sorry if this is a 
> dumb question.
> I want to draw a bunch of rectangles and sub-rectangles on a canvas 
> and have something happen when each sub-rectangle is moused over. I 
> was thinking about just making each sub-rectangle its own canvas so it 
> can handle the 'enter mouse event, but some of the rectangles need to 
> be rotated so I don't think that would work.
> Ideally I want to define each rectangle as it's own entity with 
> sub-rectangles inside of it that can handle mouse events. Then I want 
> to be able to translate and rotate that entity (or place it on the 
> canvas) and have the mouse-handling regions automatically move with 
> it. However, I don't know of anything that can both be drawn with a 
> transformation matrix and handle mouse events at the same time, so I'm 
> wondering what things I need to put together and how I should combine 
> them to get the desired behavior.
> Any suggestions would be appreciated. Thanks.
> -Nick
> ____________________
>    Racket Users list:
>    http://lists.racket-lang.org/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120409/99f9ad72/attachment.html>

Posted on the users mailing list.