<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239883</link>
    <title>MATLAB Central Newsreader - ButtonDownFcn Callback for Axes Objects</title>
    <description>Feed for thread: ButtonDownFcn Callback for Axes Objects</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Tue, 25 Nov 2008 07:33:04 -0500</pubDate>
      <title>ButtonDownFcn Callback for Axes Objects</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239883#613103</link>
      <author>Thiago </author>
      <description>For some reason, my ButtonDownFcn callback for an axes object is not responsive; no matter which mouse button I use. I'm running MATLAB 7 (R14). That feature should work the same way as it does with push buttons, don't you think? Your assistance is highly appreciated.&lt;br&gt;
&lt;br&gt;
Thiago </description>
    </item>
    <item>
      <pubDate>Tue, 25 Nov 2008 07:51:04 -0500</pubDate>
      <title>Re: ButtonDownFcn Callback for Axes Objects</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239883#613105</link>
      <author>Bruno Luong</author>
      <description>&quot;Thiago &quot; &amp;lt;thiago@mathworks.com&amp;gt; wrote in message &amp;lt;ggg9ng$c4m$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; For some reason, my ButtonDownFcn callback for an axes object is not responsive; no matter which mouse button I use. I'm running MATLAB 7 (R14). That feature should work the same way as it does with push buttons, don't you think? Your assistance is highly appreciated.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thiago &lt;br&gt;
&lt;br&gt;
I believe because axes mouse might be hidden since figure mouse superimpose. Please check Parent figure properties.&lt;br&gt;
&lt;br&gt;
Bruno</description>
    </item>
    <item>
      <pubDate>Tue, 25 Nov 2008 16:55:57 -0500</pubDate>
      <title>Re: ButtonDownFcn Callback for Axes Objects</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239883#613200</link>
      <author>Steven Lord</author>
      <description>&lt;br&gt;
&quot;Thiago &quot; &amp;lt;thiago@mathworks.com&amp;gt; wrote in message &lt;br&gt;
news:ggg9ng$c4m$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; For some reason, my ButtonDownFcn callback for an axes object is not &lt;br&gt;
&amp;gt; responsive; no matter which mouse button I use. I'm running MATLAB 7 &lt;br&gt;
&amp;gt; (R14). That feature should work the same way as it does with push buttons, &lt;br&gt;
&amp;gt; don't you think? Your assistance is highly appreciated.&lt;br&gt;
&lt;br&gt;
Do you have something else (like an image) on your axes?  If so, change the &lt;br&gt;
HitTest property of the image.&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/support/solutions/data/1-1B03X.html?solution=1-1B03X&quot;&gt;http://www.mathworks.com/support/solutions/data/1-1B03X.html?solution=1-1B03X&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
Did you PLOT on your axes between setting the ButtonDownFcn and attempting &lt;br&gt;
to trigger it?  If so, that would clear your ButtonDownFcn unless you used &lt;br&gt;
HOLD ON to prevent it.&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/support/solutions/data/1-3K8R2L.html?solution=1-3K8R2L&quot;&gt;http://www.mathworks.com/support/solutions/data/1-3K8R2L.html?solution=1-3K8R2L&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Steve Lord&lt;br&gt;
slord@mathworks.com </description>
    </item>
    <item>
      <pubDate>Wed, 26 Nov 2008 00:52:02 -0500</pubDate>
      <title>Re: ButtonDownFcn Callback for Axes Objects</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239883#613286</link>
      <author>Thiago </author>
      <description>Steve,&lt;br&gt;
&lt;br&gt;
Yes, I have images on my axes. Thank you for the suggestions, by the way. Unfortunately the problem is not completely resolved. I have results with set(gcf,'WindowButtonDownFcn', '...callback goes here....') inside the CreateFcn of an axis object. However, I can't do this for more than one axis object. For this reason, I may use push buttons instead. &lt;br&gt;
&lt;br&gt;
PS: If you know a way to overcome this problem, please let me know.</description>
    </item>
    <item>
      <pubDate>Wed, 26 Nov 2008 15:18:03 -0500</pubDate>
      <title>Re: ButtonDownFcn Callback for Axes Objects</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239883#613402</link>
      <author>Thiago </author>
      <description>To make it clear, this is just about replacing buttons by graphics (while retaining the callback capability). It's because of the fact that every GUI may change appearance once you test it in different systems. If anyone knows how to do it, please let me know.</description>
    </item>
    <item>
      <pubDate>Wed, 26 Nov 2008 17:02:02 -0500</pubDate>
      <title>Re: ButtonDownFcn Callback for Axes Objects</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239883#613421</link>
      <author>Malcolm Lidierth</author>
      <description>Could you not test for what has been clicked upon in the WindowButtonDownFcn, e.g. using gca which should change when you click on a specific axes. Also there is the hittest() function - undocumented but returns the handle of the last object clicked on.&lt;br&gt;
ML</description>
    </item>
    <item>
      <pubDate>Fri, 28 Nov 2008 22:22:02 -0500</pubDate>
      <title>Re: ButtonDownFcn Callback for Axes Objects</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239883#613787</link>
      <author>Ryan Ollos</author>
      <description>&quot;Thiago &quot; &amp;lt;thiago@mathworks.com&amp;gt; wrote in message &amp;lt;ggi6ji$n95$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Steve,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Yes, I have images on my axes. Thank you for the suggestions, by the way. Unfortunately the problem is not completely resolved. I have results with set(gcf,'WindowButtonDownFcn', '...callback goes here....') inside the CreateFcn of an axis object. However, I can't do this for more than one axis object. For this reason, I may use push buttons instead. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; PS: If you know a way to overcome this problem, please let me know.&lt;br&gt;
&lt;br&gt;
Get the position of the button click,&lt;br&gt;
cp = get(gcf, 'CurrentPoint')&lt;br&gt;
Get the Position properties of all of the the axes objects&lt;br&gt;
Test if cp is within an axes object and execute code accordingly.</description>
    </item>
    <item>
      <pubDate>Sun, 30 Nov 2008 11:49:02 -0500</pubDate>
      <title>Re: ButtonDownFcn Callback for Axes Objects</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239883#613961</link>
      <author>Ryan Ollos</author>
      <description>&quot;Malcolm Lidierth&quot; &amp;lt;ku.ca.lck@htreidil.mloclam&amp;gt; wrote in message &amp;lt;ggjvea$sfh$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Could you not test for what has been clicked upon in the WindowButtonDownFcn, e.g. using gca which should change when you click on a specific axes. Also there is the hittest() function - undocumented but returns the handle of the last object clicked on.&lt;br&gt;
&amp;gt; ML&lt;br&gt;
&lt;br&gt;
I don't find that there is a hittest function (in r2008b), and the hittest property is different than what you are referring to, as someone mentioned earlier in this thread.&lt;br&gt;
&lt;br&gt;
I think what you are referring to is: get(handle_figure, 'CurrentObject')&lt;br&gt;
&lt;br&gt;
There is a thorough discussion and example of how to implement what Thiago describes (i.e. replacing buttons by graphics) in this book: &lt;a href=&quot;http://www.mathworks.com/support/books/book13266.html.&quot;&gt;http://www.mathworks.com/support/books/book13266.html.&lt;/a&gt; </description>
    </item>
    <item>
      <pubDate>Mon, 01 Dec 2008 18:15:03 -0500</pubDate>
      <title>Re: ButtonDownFcn Callback for Axes Objects</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239883#614239</link>
      <author>Malcolm Lidierth</author>
      <description>Ryan&lt;br&gt;
The hittest() command is present in R2008b. It has been around for a long time although it is still undocumented. How it differs, if at all, from&lt;br&gt;
get(gcf, 'CurrentObject') I do not know.&lt;br&gt;
ML</description>
    </item>
    <item>
      <pubDate>Mon, 01 Dec 2008 19:58:02 -0500</pubDate>
      <title>Re: ButtonDownFcn Callback for Axes Objects</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239883#614274</link>
      <author>Yair Altman</author>
      <description>&quot;Malcolm Lidierth&quot; &amp;lt;ku.ca.lck@htreidil.mloclam&amp;gt; wrote in message &amp;lt;gh19j7$2o0$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Ryan&lt;br&gt;
&amp;gt; The hittest() command is present in R2008b. It has been around for a long time although it is still undocumented. How it differs, if at all, from&lt;br&gt;
&amp;gt; get(gcf, 'CurrentObject') I do not know.&lt;br&gt;
&amp;gt; ML&lt;br&gt;
&lt;br&gt;
If memory serves me and I'm not mistaken, the difference is that get(gcf, 'CurrentObject') returns the latest object selected, whereas hittest (and the semi-documented overobj function) return the topmost object beneath the mouse cursor, even if it has not been selected.&lt;br&gt;
&lt;br&gt;
If you're interested in checking the current position in the WindowButtonMotionFcn callback, you should use either overobj() (which has some severe limitations, but is outside the scope here), hittest(), or get(gcf,'CurrentPoint') (note: CurrentPoint, not CurrentObject).&lt;br&gt;
&lt;br&gt;
Yair Altman&lt;br&gt;
UndocumentedMatlab.com (actual content sometime in the future...)</description>
    </item>
    <item>
      <pubDate>Mon, 01 Dec 2008 22:54:01 -0500</pubDate>
      <title>Re: ButtonDownFcn Callback for Axes Objects</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239883#614312</link>
      <author>Jiro Doke</author>
      <description>&quot;Thiago &quot; &amp;lt;thiago@mathworks.com&amp;gt; wrote in message &amp;lt;ggi6ji$n95$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Steve,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Yes, I have images on my axes. Thank you for the suggestions, by the way. Unfortunately the problem is not completely resolved. I have results with set(gcf,'WindowButtonDownFcn', '...callback goes here....') inside the CreateFcn of an axis object. However, I can't do this for more than one axis object. For this reason, I may use push buttons instead. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; PS: If you know a way to overcome this problem, please let me know.&lt;br&gt;
&lt;br&gt;
Why not use the ButtonDownFcn property for the axes, not the figure. Then each axes can have its own ButtonDownFcn behavior. Also, as Steve suggested, be sure to set the HitTest property of the images to 'off'.&lt;br&gt;
&lt;br&gt;
jiro</description>
    </item>
    <item>
      <pubDate>Tue, 02 Dec 2008 01:55:03 -0500</pubDate>
      <title>Re: ButtonDownFcn Callback for Axes Objects</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/239883#614351</link>
      <author>Kenneth Eaton</author>
      <description>&quot;Thiago &quot; &amp;lt;thiago@mathworks.com&amp;gt; wrote in message &amp;lt;ggjpbb$c5d$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; To make it clear, this is just about replacing buttons by graphics (while retaining the callback capability). It's because of the fact that every GUI may change appearance once you test it in different systems. If anyone knows how to do it, please let me know.&lt;br&gt;
&lt;br&gt;
Thiago,&lt;br&gt;
&lt;br&gt;
I'm not totally sure of what you want, but it may be like what I did for rotating the camera in a game I posted to the FEX (&quot;Staker&quot;). The idea was this... I designed the WindowButtonDownFcn to look for clicks in the figure. I didn't use the ButtonDownFcn of the axes since the axes was actually not visible (and I don't remember it working in that case). It then checked the position of the mouse click relative to the position of the axes to see if it was inside it, and if so it took the appropriate action (left click = rotate, right click = pan, middle click = zoom). It could be expanded to work with multiple axes in the same figure if you needed it to. You can peek into the code for the game (although it is long) and in particular check out a couple key functions. I believe &quot;mouse_game&quot; may be one of them, but I don't remember offhand the naming convention I had for that older version since I've been working on a newer one.&lt;br&gt;
&lt;br&gt;
If this sounds like the sort of behavior you want, check it out and I can give you more info about it as needed.&lt;br&gt;
&lt;br&gt;
Ken</description>
    </item>
  </channel>
</rss>

