clicking on an image with transparency

Daniel Fuchs daniel.fuchs at oracle.com
Fri Sep 28 00:57:27 PDT 2012


On 9/28/12 4:56 AM, openjfx-dev-request at openjdk.java.net wrote:
> Message: 4
> Date: Fri, 28 Sep 2012 04:57:53 +0200
> From: Tom Eugelink<tbee at tbee.org>
> Subject: clicking on an image with transparency
> To:openjfx-dev at openjdk.java.net
> Message-ID:<50651231.1050509 at tbee.org>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> In some of my controls I have some images that are being used as icons. When the user clicks on these icons, a popup should open or close. For these images I use PNGs with have some transparency in them and an onMouseClick event handler won't react on these transparent areas. So now I wrap the ImageView in a Pane and do the on-click on the pane. That works, but seems like a bit of overkill. Group won't do it.
>
> What is the best way to detect a mouse click on any area of an ImageView?
Hi Tom,

In SceneBuilder we configure images that you import with 
pickOnBounds=true by default. The API default is false.
If you want the mouse handlers to react to transparent area I'd suggest 
arranging for ImageView objects to
have pickOnBounds set to true.

Hope this helps,

-- daniel
>
> Tom
>
> PS: I would have like to use SVG images, but apparently loading a SVG file is not part of JavaFX?



More information about the openjfx-dev mailing list