ImageView with transparent image not clickable

I created an ImageView with an image with transparent portions. I also did some scaling and moving, which I though might cause this effect, but that is not the case. When I click on the transparent portion of the image the onMouseClick event is not fired. Other mouse events (mouse enter, mouse move, mouse exit, ...) get fired. Only when I click on the non transparent part the click event is fired.
Image img = new Image(getClass().getResourceAsStream("barrel_icon.png"));
ImageView view = new ImageView(img);
view.setScaleX(0.5);
view.setScaleY(0.5);
view.setOnMouseClicked(new EventHandler<MouseEvent>() {
    @Override
    public void handle(MouseEvent mouseEvent) {
    System.out.println("Clicked on the scaled icon");
StackPane root = new StackPane();
Group group = new Group(view);
group.setManaged(false);
group.setLayoutY(-13);
group.setLayoutX(-13);
root.getChildren().add(group);
The area between the barrel and the shadow belongs clearly to the image, however is transparent.
I am wondering if there is a reason for this behaviour and what is the best way to work around this issue, as my image has large transparent portions and the non transparent parts are hard to click on.
By the way this is all based on JavaFX 2.2.
Regards
Hotzst

For future reference here is the workaround I have come up with:
public class TransparentImageViewClickableArea extends Rectangle{
    private final ImageView imageView;
    public TransparentImageViewClickableArea(ImageView imageView) {
        super(imageView.getLayoutX(), imageView.getLayoutY(), imageView.getImage().getWidth(), imageView.getImage().getHeight());
        setOnMouseReleased(imageView.getOnMouseReleased());
        this.imageView = imageView;
        bindBounds();
    private void bindBounds() {
        DoubleBinding layoutXBinding = new DoubleBinding() {
                super.bind(imageView.layoutXProperty(), imageView.scaleXProperty());
            @Override
            protected double computeValue() {
                final double imgWidth = imageView.getImage().getWidth();
                final double actualWidth = imgWidth * imageView.getScaleX();
                double diff = imgWidth - actualWidth;
                return imageView.getLayoutX() + diff/2;
        layoutXProperty().bind(layoutXBinding);
        DoubleBinding layoutYBinding = new DoubleBinding() {
                super.bind(imageView.layoutYProperty(), imageView.scaleYProperty());
            @Override
            protected double computeValue() {
                final double imgHeight = imageView.getImage().getHeight();
                final double actualHeight = imgHeight * imageView.getScaleY();
                double diff = imgHeight - actualHeight;
                return imageView.getLayoutY() + diff/2;
        layoutYProperty().bind(layoutYBinding);
        widthProperty().bind(imageView.getImage().widthProperty().multiply(imageView.scaleXProperty()));
        heightProperty().bind(imageView.getImage().heightProperty().multiply(imageView.scaleYProperty()));
It is not a perfect solution, as it does not consider the case that the image might be changed as well. This however could be improved easily but was not necessary in my use case.

Similar Messages

  • Photoshop image with transparent bg not transparent in FCP

    My psd images with transparent backgrounds (done correctly) are showing up with white backgrounds when I import them into FCP. How can this be remedied? please let me know!

    i have a .psd and a .tif file..how do i switch it to 8-bit? i think its grayscale mode right now and the option for 8bit is grayed out and not clickable

  • Creating a PDF with Transparent Images

    Hi,
    Here is my problem:
    I am using Acrobat 9. I design posters in another program. I print to PDF.
    I design the poster and must put a logo in it with a transparent background. Note: If the poster background is white I never have any problems.
    This poster has a pink background and hence I have to put the logo into the poster in a graphic type of gif or tiff or png to maintain transparency.
    All is fine in my design program - transparency is fine etc.
    I print to PDF (Acrobat 9.0) and the dreaded white box occurs. Note, I put an old version of the logo, one I cannot use, and it maintained its transparency fine. So this means that some gif files Acrobat 9.0 keeps transparency and some it does not.
    So, in summary, I have tried all types of file formats gif, png, tiff and all types of programs to remove the logo background and save as one of the later formats and NONE maintain the transparency in the PDF output.
    I have even tried saving the whole poster as a jpeg - but the quality was too poor to print.
    I have used Word, Photoshop, MS Photodraw, Elements etc.
    I have no idea why a gif I have from years ago works and one that I am creating now maintain their tranparency in the PDF.
    I am under a deadline and am VERY worried this will not get done.
    I am immensely grateful for any help - I have been at this for countless weeks and hours...
    Thanks,
    Elisabeth

    I am using MS Publisher and even Word 2010 for poster design and have used multiple programs (and multiple formats that support transparency)  for logo editing - removal of background - Photoshop, etc.
    I place logos, both gifs, with transparent backgrounds in a document and print PDF and one or none will show transparency - it makes no sense at all.
    Most of the time the background is a white block. It couldnt be more frustrating.
    It is a simple document/poster with just a few words of text and a logo...
    Are there settings in Acrobat 9.0 that need to be turned on that I am missing. I had no trouble with Acrobat 7 - it worked EVERY time.
    I was on  with tech support for 5 hrs and there was no knowledge of this - he just wanted to reinstall 7.0 which did not work.
    Need ideas - overprinting is on. I noticed that flattening doesnt allow me to pick transparent objects - have no ideas if I am even on the right track.
    Have read everything I can find online regarding Acrobat 9.0, PDF creation and transparent logo backgrounds.
    Sooo grateful for any help!
    Thanks,
    Elisabeth

  • InDesign PDF transparent images not printing right background color.

    problem with exporting an InDesign Document to a PDF and printing. My transparent images are showing up with a darker background than what they are placed on. Know how to help?

    Thanks everyone!  That really helped.
    There were a few other things that I had to make sure of also.
    Solution:
    Images placed in InDesign that were made in Photoshop or another program should be in ckmy format.  The background needs to be in the same ckmy.   Transparency blend must be set at CKMY, then Transparency Flattener presents must be set at Rasters/Vectors: 0 Line art and text resolution: 600, Gradient and mesh resoltuion 300.  Exporting to PDF must be done under present PDF/X-4:2008 Compatibility: Acbrobat 7.

  • Problem with transparent image

    Hi everyone,
    I'm having problem with embedding transparent image to PDF. Thin border appears  when viewing the document with Adobe Reader, Adobe Acrobat Pro and even with Foxit Reader. But there are no such border in the image.
    After some experiments I found that this border appears on the edge of fully transparent black and fully opaque white areas. And changing fully transparent black color to fully transparent white removes the border.
    Is this an expected behaviour of Adobe Reader or is it a bug? Could anyone explain in which other cases such artifacts may appear?
    Thanks in advance.

    It is related to the source from which PDF document is generated. Anyway if writing the image as is without pattern the problem still remains.
    Here is example without pattern http://www.filefactory.com/file/3g711cx94n1b/n/testImage_pdf

  • Transparent image not recognized as transparent

    I am loading a PNG with transparency into a UILoader. This
    part works correctly, transparency and all.
    Now I need to find out the rectangle that is transparent. I
    found the getColorBoundsRect() function, and copied the
    UILoader.content into a bitmapData, but when I run the
    getColorBoundsRect it comes back with a Rectangle that has no width
    or height - IE, it finds no transparent pixels.
    To test, I tried using getPixel32 on an area of the image I
    know is transparent, and it comes back to tell me that the pixel
    alpha is 255?
    Applicable code is attached.

    I am an idiot. I forgot to set a parameter in the BitmapData
    constructor, which tells it to keep transparent pixels transparent.
    BitmapData defaults to changing transparent pixels to white, which
    is why I was having problems.
    var clBD:BitmapData = new
    BitmapData(735,600,true,0x00FFFFFF);

  • ImageView with transparency

    I have an ImageView which contains an Image that has transparency. The default behavior for ImageView is to not fire mouse events on parts of the image that are fully transparent. However, I want events on all pixels in the image, regardless of their opacity.
    Rectangle has this behavior by default, that is, if you create a Rectangle like this:
    var r = Rectangle {
    fill: Color.color(0,0,0,0);
    width: 136
    height: 19
    onMouseMoved: function(Void) {
    println("mouse moved");
    you'll see the printout even though the rectangle isn't visible.
    Is there any way to do the same for ImageView?
    -Ken

    You almost answered yourself: a possible workaround is to put a transparent rectangle over the ImageView and let it handle the events.
    Maybe there is something simpler or more elegant, but hey, if nobody else has a suggestion... :-)

  • Lightbox images not clickable on iPhone

    I have created a lightbox for my site portfolio.danielmusica.com that works great on the desktop and ipad. But when you view it on the iPhone, the images that are clickable wont bring up the videos.

    It's not just you. A whole host of people, including me, started having this issue today.  I have a 3GS running 5.0.1.  I have been reading or the couple hours and it seems it's a cross platform issue, not an iPhone issue.  Seems to be something wrong with google mobile image search. Some are reporting success with switching from mobile to classic view in google. 
    Now I think we need to just wait on google to fix the issue.

  • Png with transparent background not rendering on the mac

    I created a png with a transparent background for a header.  It renders fine on the ipad and iphone but not on the mac.  Is there a reason why? The header is on http://surfingthebluemarble.com/news.html
    Thanks in advance for your help!
    Regards,
    umbre gachoong

    If the header in question is the News on the Blue Marble header it seems to be rendering fine on the page and fine if I download the image to my system.
    The background is transparent.

  • Podcasts with embedded images not working

    I am trying to play this podcast https://itunes.apple.com/gb/podcast/the-british-library-podcast/id935352158?mt=2 which contains embedded chapter images.
    It plays fine within iTunes on a Mac but it doesn't work on my iPhone 6 iOS8.
    Can anyone help me get it working. Is it even supposed to work?

    This is
    not an issue with regards to the actual
    PDF Language and Specification but rather, an issue of how to create PDF using Acrobat (or some other tool). Please repost in the appropriate forum (Acrobat or otherwise).
    - Dov

  • PHOTO BOOTH EFFECTS WITH BACKGROUND IMAGES NOT WORKING

    JUST TO KNOW HOW THE IMAGES BACKGROUND WORKS ON PHOTO BOOTH
    EXAMPLE PARIS THERE IS A SPACE TO PLACE THE FACE AND IS NOT WORKING.
    TKS.
    MARIA

    Just a quick update with the Zip files.
    I've downloaded 'The Unarchiver' and that will unzip fine. it seems to be an issue with apples 'Archive Utility' over network I suppose?

  • Working With Template, Images Not Showing on Web

    Please forgive me, as I know this has been asked a million times before.
    I am a newbie to this, but have tried to research before asking this question.
    I am using a template (HTML5) and it's showing up beautifut ully in Dreamweaver and in the Live Preview, but when I upload to my hosting account (GoDaddy), the images don't show up. I have uploaded all the image files to the hosting as well. I have called GoDaddy, it is not a hosting issue.
    I have been fighting with this for three days and I'm at wits end.
    collarsforchange.org

    Hi Katie,
    What is the difference between a Local Site folder and a general folder on my computer? Where can I locate this Local Site folder?
    The Local site folder will store you HTML pages and other related assets of you site locally on your computer in one place.You need to define a general folder to be the site's local folder in Dreamweaver.
    Please refer this http://helpx.adobe.com/dreamweaver/using/set-local-version-site.html
    Does the home page need to be installed IN root folder or can it be underneath?
    The home page which is usually the index.html needs to be placed in the root folder.
    Thanks
    Bhawna

  • Question on PDF files with linked images (not embedded) between Reader and Illustrator

    I run into situations when I get customer PDFs that need to be edited. When they load in Acrobat Reader it works fine. However if I load it into Illustrator it asks me to point it to the linked file. The question is how does Acrobat Reader open a PDF file and show a linked file when it is not embedded? Why can't Illustrator do the same thing?
    This is more of a technical question, but any information would be helpful.  Thanks.

    For linked images, your PDF file contains a thumbnail image along with the reference or address of the actual image. Reader will display this thumbnail. Now, wanting to edit the PDF in Illustrator, it wants to enable you working on the actual image. Hence it asks you to point to the linked file.
    HTH

  • Help with background image (Not sure how to ask this..........)

    I have just started to try and make my first site. I designed it in Photoshop first as I learned in many tutorials. I don't know why my background image looks like this when I scale down below 100%, but at 100% or "fit all"&"fit width" it doesn't change and I can't move it with the hand tool or scroll it. I'm sorry, I'm just learning.
    Thank you.

    Hello,
    in addition, I tried this (page properties = translated from my German DW) too an the only difference had been this "missing end bracket".
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>ioneglines.com</title>
    <style type="text/css">
    body {
    background-image: url(myImage.png);
    background-repeat: no-repeat;
    </style>
    </head>
    <body>
    </body>
    </html>
    ... before you insert your image as a background image, you have to give it the dimensions, you want to see in your file. Please use try and error method.
    Hans-Günter

  • Strange problem with transparent image rendering on iOS

    I have UIImageView, which is used for showing image from resources. Image appears to be distorted. It is especially visible if you zoom the image in a graphics editor.
    UIImageView size matches the size of the image.
    currently used UIImageView parameters.
    imgHeader.contentMode = UIViewContentModeCenter;
    imgHeader.image = [UIImage imageNamed:@"logo.png"];
    imgHeader.opaque = TRUE;
    imgHeader.clearsContextBeforeDrawing = TRUE;
    For UIImageView I tried changing parameters "opaque", "clearsContextBeforeDrawing" and "contentMode". Same result.
    For resolving this issue I have also wrote classes AliasedLayer and AliasedImageView  ( for antialiasing disabling the use of CGContextSetShouldAntialias and CGContextSetAllowsAntialiasing )
    This is approximate code, there have been many attempts to change the code to correct image distortion. Same result.
    @implementation AliasedLayer
    -(id)init
    self = [super init];
    if (self) {
         img = [UIImage imageNamed:@"logo.png"];
    return self;
    -(void)drawInContext:(CGContextRef)context
    CGContextSetAllowsAntialiasing(context, false);
    CGContextSetShouldAntialias(context, false);
    CGContextDrawImage(context, CGRectMake(0., 0., 55., 18.), [img CGImage]);
    - (void)renderInContext:(CGContextRef)ctx
    CGContextSetAllowsAntialiasing(ctx, false);
    CGContextSetShouldAntialias(ctx, false);
    @end
    @implementation AliasedImageView
    - (id)initWithFrame:(CGRect)frame{
        if (self = [super initWithFrame:frame]) {
            [self setClearsContextBeforeDrawing:YES];
    self.backgroundColor = [UIColor clearColor];
        return self;
    -(void)setImage:(UIImage *)img
    [image release];
    image = img;
    [image retain];
    - (void)setNeedsDisplay{
        [self setNeedsDisplayInRect:self.frame];
    -(void)dealloc
    [image release];
    [super dealloc];
    +(Class)layerClass
    return [AliasedLayer class];
    - (void)drawRect:(CGRect)rect
    [super drawRect:rect];
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGContextSetInterpolationQuality(ctx, kCGInterpolationHigh);
    CGContextSetAllowsAntialiasing(ctx, false);
    CGContextSetShouldAntialias(ctx, false);
    CGContextDrawImage(ctx, rect, [image CGImage]);
    -(void)awakeFromNib
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGContextSetAllowsAntialiasing(ctx, false);
    CGContextSetShouldAntialias(ctx, false);
    [super awakeFromNib];
    @end
    There have been attempts to dynamically load the image as well as using xib file. Same result - logo image is distorted.
    Any ideas on what is causing this and how to fix it?

    In xib file, you have image view. Click on, and try to change the mode in View. Your logo image is perhaps distorted because you are in "Scall to fill"... Try "Aspect Fit".

Maybe you are looking for