spotting a mouseclick in the transparent area of an image

Ben Rubinstein benr_mc at cogapp.com
Thu Mar 30 13:52:18 EDT 2017


I have a group containing a grid of square images.

Some of the images are gifs, some are pngs, and some of the latter have an 
alpha channel with some transparent bits.

The images are all used as buttons, to control something else - the images in 
essence are labels or icons for the buttons. The images have 3d borders to 
make them look more button-like.

The problem is that the if the user happens to click in the transparent area 
of an image, the target of the mouseup isn't the image but the card. But the 
image is a button, so I want to catch mouseup anywhere in this square image.

I thought that I might be able to use 'the mousecontrol', when the target was 
the card, to find out which image the mouse was in when; but this too takes 
account of the transparency of the image.

I can see this is a really useful feature - but in this case I want the 
opposite! Is there a flag somewhere, or another easy way to achieve this?

The non-easy ways I'm aware of are:
	- hide all the images and replace them with buttons referencing the images
	- re-compositing the images to flatten the alpha channel
	- iterating through all the images - there are many, in a scrolling group - 
testing for the mouseloc within the rect of each


Is there anything simpler than this, to treat an image as opaque for the 
purposes of hit-testing?

TIA

Ben






More information about the use-livecode mailing list