On Friday 21 Feb 2003 11:50 am, you wrote:
> Problem:
> I need a quick way to determine which hot area was clicked on and call
> it's function. So I'm wondering what data structure would I use so that
> once I figure out the location of the click, I can quickly retrieve the
> function call? I mean, if I have an array, how do I index it in such a
> way that I can calculate the location of the mouse click to be an index
> of this array?
Many years ago I had a similar requirement. I built another ("colour") map
with identical dimensions. It was not displayed, but had areas that matched
those on the real map. These areas were coloured according to the function
desired for that position on the real map.
When the user clicks on the real map, grab the co-ordinates of the click and
get the colour of the corresponding pixel in the colour map. From the colour,
it's simple to determine the function wanted. You can easily provide a lot of
detail and flexibility, and the processing is simple.