spotting a mouseclick in the transparent area of an image

Mike Bonner bonnmike at gmail.com
Thu Mar 30 14:08:52 EDT 2017


Place a grc of the right size behind the image. Make sure the grc is set to
opaque. Group the grc and the image and place your mouseup handler in the
group.  If they click a visible portion of the image it'll fire the groups
mouseup, if they click a trasnarent spot, the (blended and invisible) grc
will still cause the mouseup to fire.



On Thu, Mar 30, 2017 at 11:52 AM, Ben Rubinstein via use-livecode <
use-livecode at lists.runrev.com> wrote:

> 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
>
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list