Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: ButtonPressFcn behaves strangely

Subject: ButtonPressFcn behaves strangely

From: jay vaughan

Date: 13 May, 2008 16:56:03

Message: 1 of 4

Hi,

I am running a GUI with an axes in it. When I start the GUI
the axes are empty. During this time I am able to click on
the figure and return a (diagnostic) message. I did the same
for the GUI itself, and both work.

% --- Executes on mouse press over axes background.
function axes1_ButtonDownFcn(hObject, eventdata, handles)
disp('mouse button pressed on axes1');


% --- Executes on mouse press over figure background.
function figure1_ButtonDownFcn(hObject, eventdata, handles)
disp('mouse button pressed on figure1');

But once I use image(frame) to display a frame in the axes,
axes1_ButtonDownFcn can not be called anymore by mouse
clicks on the axes, although figure1_ButtonDownFcn still can
get called by mouse clicks on the figure background. This
puzzles me quite a bit. Any ideas how I could fix this so
that ButtonDownFcn continues to work after image(frame)?

Thanks,
J

Subject: Re: ButtonPressFcn behaves strangely

From: jay vaughan

Date: 13 May, 2008 17:13:03

Message: 2 of 4

"jay vaughan" <jvaughan5.nospam@gmail.com> wrote in message
<g0ch73$79t$1@fred.mathworks.com>...
> Hi,
>
> I am running a GUI with an axes in it. When I start the GUI
> the axes are empty. During this time I am able to click on
> the figure and return a (diagnostic) message. I did the same
> for the GUI itself, and both work.
>
> % --- Executes on mouse press over axes background.
> function axes1_ButtonDownFcn(hObject, eventdata, handles)
> disp('mouse button pressed on axes1');
>
>
> % --- Executes on mouse press over figure background.
> function figure1_ButtonDownFcn(hObject, eventdata, handles)
> disp('mouse button pressed on figure1');
>
> But once I use image(frame) to display a frame in the axes,
> axes1_ButtonDownFcn can not be called anymore by mouse
> clicks on the axes, although figure1_ButtonDownFcn still can
> get called by mouse clicks on the figure background. This
> puzzles me quite a bit. Any ideas how I could fix this so
> that ButtonDownFcn continues to work after image(frame)?
>
> Thanks,
> J


"jay vaughan" <jvaughan5.nospam@gmail.com> wrote in message
<g0ch73$79t$1@fred.mathworks.com>...
> Hi,
>
> I am running a GUI with an axes in it. When I start the GUI
> the axes are empty. During this time I am able to click on
> the figure and return a (diagnostic) message. I did the same
> for the GUI itself, and both work.
>
> % --- Executes on mouse press over axes background.
> function axes1_ButtonDownFcn(hObject, eventdata, handles)
> disp('mouse button pressed on axes1');
>
>
> % --- Executes on mouse press over figure background.
> function figure1_ButtonDownFcn(hObject, eventdata, handles)
> disp('mouse button pressed on figure1');
>
> But once I use image(frame) to display a frame in the axes,
> axes1_ButtonDownFcn can not be called anymore by mouse
> clicks on the axes, although figure1_ButtonDownFcn still can
> get called by mouse clicks on the figure background. This
> puzzles me quite a bit. Any ideas how I could fix this so
> that ButtonDownFcn continues to work after image(frame)?
>
> Thanks,
> J

Sorry for the quick reply...I wanted to add that mouse
clicks at the very edge of the axes do call
axes1_ButtonDownFcn, but not mouse clicks in the interior.
If it is helpful, I am also using a function to return mouse
position, although disabling this function (i.e. removing
the WindowButtonMotionFcn callback) did not restore the
mouse clicks in the interior of the axes after image(frame).

J

Subject: Re: ButtonPressFcn behaves strangely

From: matt dash

Date: 13 May, 2008 17:35:04

Message: 3 of 4

The image is in front of the axes so you are clicking the
image, not the axes. Turn the hittest property of the image
off and you'll be fine.


Subject: Re: ButtonPressFcn behaves strangely

From: jay vaughan

Date: 13 May, 2008 18:03:03

Message: 4 of 4

"matt dash" <n.a@mail.com> wrote in message
<g0cjg8$qke$1@fred.mathworks.com>...
> The image is in front of the axes so you are clicking the
> image, not the axes. Turn the hittest property of the image
> off and you'll be fine.
>
>

Matt,

that worked perfectly. Thanks!


J

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
buttondownfcn jay vaughan 13 May, 2008 13:00:25
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics