You can't get information which image you clicked (unless there's some OpenGL stuff that does it, but I don't know it)
But if you store the x/y position of sprites, you can check the clicked sprite by using the x/y values from your data.
Example:
your zone look like this: zone = [x, y, image]
you draw them like this: zone[2].draw(zone[0], zone[1], 0)
you can check if your cursor is over zone by: mouse_x.between?(zone[0], zone[0] + zone[2].width) and mouse_y.between?(zone[1], zone[1] + zone[2].height)
If you have few zones, you just iterate them to perform these actions.
I'm also working on a gui right now. I think people here have already given some great advice about how to detect the sprite you are mousing over, so i don't think my methods would contribute anything new. I like to use hit boxes and hit circles for both physics and cursor interaction (the cursor being, after, just another sprite.). For complex shapes use a combination of these hitbox primitives. The basic idea is to restrict click-able sprites so they are simply not allowed to overlap. On some Ruby/SDL projects, I had pixel-precise-alpha-channel-ignoring precision in my detection methods; to do this in Gosu would require mapping your img's #blob data into a 'collision map' capable of taking an x,y from your cursor, applying whatever scale and transformation your of your view angle, and then searching the relevant collision map for a transparent/false value or a clickable/true value. Doing all this, however, seems to go against the entire philosophy behind the simplicity coding with Gosu. You might want to consider forgoing some level of 'desired' precision for an 'acceptable' level of precision, although I suppose I shouldn't discourage you from the utter badassery of pursuing the the former.
However you approach, assume we have some hitbox object with a #detect(x,y) method, and let's consider optimization:
Your mouse can only ever be in ONE location at any given frame, so given a list of geometries:
@hitboxes = [ hitbox0, hitbox1, ... ]
Remember a value between 0 and hitboxes.size, the last hitbox your mouse was detect in, and only check this one element until it is nolonger detected:
@hitboxes[@value].detect(x,y)
if this method returns false, we might need some enumeration over the hitboxes array to re-set value. This reduces the time spent enumerating through the list. if #detect(x,y) returns a bool, you could do something like this:
x = YourGosuWindow.mouse_x
y = YourGosuWindow.mouse_y
if @value
unless @hitboxes[@value].detect(x,y)
@value = nil
end
else
@value = @hitboxes.collect{|h| h.detect(x,y)}.rindex(true)
end
@value can be nil, or a number. Whenever a click event is evoked, you already have @value stored so all you need is some method to associate the index references of your hitbox array with your sprite array. This is just an example to illustrate the idea so it'll no doubt look much different when incorporated into your own update method, and that second-to-last line with the
@value = @hitboxes.collect{|h| h.detect(x,y)}.rindex(true)
requires further optimization especially.