Why can't I click on the middle of imrect when using AlphaData?

I've run into some peculiar situations using the imrect function where the 'patch' (the center portion) can't be clicked. Normally you can click on the patch and drag the rectangle. The problem seems to arise when I try to use AlphaData in the underlying figure.
The following code illustrates the problem I am having:
mask = magic(5);
h = image(mask);
set(h, 'AlphaData', mask*0.5);
imrect(gca, [1 1 1 1])
Without the third line there is no problem. Otherwise I need to turn off the 'HitTest' property of the underlying image in order to be able to click on the patch. Like this:
mask = magic(5);
h = image(mask)
set(h, 'AlphaData', mask*0.5);
set(h,'HitTest','off')
imrect(gca, [1 1 1 1])
I can't seem to track down the cause of the problem and other parts of the rectangle don't exhibit this behavior.
I'm using version 7.5.0.342 (R2007b).

Answers (1)

Well, it seems you found a workaround that works, so what are you looking for now? Another workaround? Or just confirmations that it behaves that way for others also? If so, I can verify that it operates as you say. Other than that about all I can say is that's how it behaves. I never use imrect() anyway - I don't like how it works. I use rbbox instead - it doesn't ask for confirmation of size and location or give you handles, you just click and drag out a box.

1 Comment

A workaround is fine for now but I would like a better understanding of where the problem arises. Is it a problem with how I'm coding, just a glitch in one of the Matlab functions, or something else?

Sign in to comment.

Categories

Asked:

on 14 Mar 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!