<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Advanced MATLAB: ButtonDownFcn</title>
	<link>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/</link>
	<description>&#60;a href="http://www.mathworks.com/matlabcentral/fileexchange/loadAuthor.do?objectId=969735&#38;objectType=author"&#62;Bob&#60;/a&#62;, &#60;a href="http://www.mathworks.com/matlabcentral/fileexchange/loadAuthor.do?objectId=1093599&#38;objectType=author"&#62;Brett&#60;/a&#62; &#38; &#60;a href="http://www.mathworks.com/matlabcentral/fileexchange/loadAuthor.do?objectId=1094142&#38;objectType=author"&#62;Jiro&#60;/a&#62; share favorite user-contributed submissions from the File Exchange.</description>
	<pubDate>Sun, 22 Nov 2009 23:14:58 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Steve L</title>
		<link>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13055</link>
		<dc:creator>Steve L</dc:creator>
		<pubDate>Fri, 20 Feb 2009 15:26:32 +0000</pubDate>
		<guid>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13055</guid>
		<description>Lorraine,

As Doug said in comment 7, by default some of the high-level graphics functions (including image) clear many of the properties of the axes.  You can restore those properties after calling IMAGE (as Doug suggested) or you can SET the axes NextPlot property to 'replacechildren' before calling IMAGE.

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/axes_props.html#NextPlot

A similar type of problem, but with PLOT and the Tag property instead of IMAGE and the ButtonDownFcn property, is described in this document on our support website; the solution is the same.

http://www.mathworks.com/support/solutions/data/1-168SX.html</description>
		<content:encoded><![CDATA[<p>Lorraine,</p>
<p>As Doug said in comment 7, by default some of the high-level graphics functions (including image) clear many of the properties of the axes.  You can restore those properties after calling IMAGE (as Doug suggested) or you can SET the axes NextPlot property to &#8216;replacechildren&#8217; before calling IMAGE.</p>
<p><a href="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/axes_props.html#NextPlot" rel="nofollow">http://www.mathworks.com/access/helpdesk/help/techdoc/ref/axes_props.html#NextPlot</a></p>
<p>A similar type of problem, but with PLOT and the Tag property instead of IMAGE and the ButtonDownFcn property, is described in this document on our support website; the solution is the same.</p>
<p><a href="http://www.mathworks.com/support/solutions/data/1-168SX.html" rel="nofollow">http://www.mathworks.com/support/solutions/data/1-168SX.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lorraine</title>
		<link>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13052</link>
		<dc:creator>Lorraine</dc:creator>
		<pubDate>Thu, 19 Feb 2009 22:15:54 +0000</pubDate>
		<guid>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13052</guid>
		<description>Doug,

   It works now, thanks : )!

Lorraine</description>
		<content:encoded><![CDATA[<p>Doug,</p>
<p>   It works now, thanks : )!</p>
<p>Lorraine</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug</title>
		<link>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13051</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Thu, 19 Feb 2009 21:40:22 +0000</pubDate>
		<guid>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13051</guid>
		<description>Lorraine,

When you call the image command, capture the handle to that, then get the parent.

Doug</description>
		<content:encoded><![CDATA[<p>Lorraine,</p>
<p>When you call the image command, capture the handle to that, then get the parent.</p>
<p>Doug</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lorraine</title>
		<link>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13050</link>
		<dc:creator>Lorraine</dc:creator>
		<pubDate>Thu, 19 Feb 2009 20:53:27 +0000</pubDate>
		<guid>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13050</guid>
		<description>Doug,
 
   Thanks, but how can i do that? 
   I tried to get the new axes by

   h = findobj(handles.Visible_iamge,...),but it returned nothing

Lorraine</description>
		<content:encoded><![CDATA[<p>Doug,</p>
<p>   Thanks, but how can i do that?<br />
   I tried to get the new axes by</p>
<p>   h = findobj(handles.Visible_iamge,&#8230;),but it returned nothing</p>
<p>Lorraine</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug</title>
		<link>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13049</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Thu, 19 Feb 2009 20:36:58 +0000</pubDate>
		<guid>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13049</guid>
		<description>Lorraine,

Some of the graphics functions create a new axes and replace the old one.  In doing this, the old callbacks, and certain other attributes are removed.  You need to set them again.

Doug</description>
		<content:encoded><![CDATA[<p>Lorraine,</p>
<p>Some of the graphics functions create a new axes and replace the old one.  In doing this, the old callbacks, and certain other attributes are removed.  You need to set them again.</p>
<p>Doug</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lorraine</title>
		<link>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13048</link>
		<dc:creator>Lorraine</dc:creator>
		<pubDate>Thu, 19 Feb 2009 20:27:48 +0000</pubDate>
		<guid>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13048</guid>
		<description>Doug,

   I try to use ButtonDownFcn to get information about image pixels in the current figure. The function works well before  the image showed in axes, but after the image loading into the axes, the ButtonDownFcn does not work. 

here is the code

%%%%%
function pushbutton_input_vimage_Callback(hObject, eventdata, handles)
 
[vname,vpath]=uigetfile('*.bmp; *.img; *.jpg; *.tif');
vimage=[vpath vname];
handles.user.plot_vimage=imread(vimage);
 
axes(handles.Visible_iamge)

image(handles.user.plot_vimage)

guidata(hObject, handles);

%%%%%
function popupmenu_vpoints_Callback(hObject, eventdata, handles)

if get(hObject, 'value')==2
   handles.mouse_track=2;
  
elseif get(hObject, 'value')==3
     handles.mouse_track=3;
   
elseif get(hObject, 'value')==4
     handles.mouse_track=4;
   
end
 
guidata(hObject, handles);

%%%%
function Visible_iamge_ButtonDownFcn(hObject, eventdata, handles)
handles.mouse_pos_fig=get(handles.figure1,'currentpoint');
axes_area=get(handles.Visible_iamge,'position');
 
if (handles.mouse_pos_fig(1)(axes_area(1))) &#38;&#38; ...
        (handles.mouse_pos_fig(2)(axes_area(2)))
    handles.mouse_pos=get(hObject,'currentpoint');
else
    handles.mouse_pos=-1;
end
 
b=handles.mouse_pos(1,1:2);
 
if handles.mouse_track==2
    set(handles.text_A,'string',int2str(b)); 
elseif handles.mouse_track==3
    set(handles.text_B,'string',int2str(b));
elseif handles.mouse_track==4
    set(handles.text_C,'string',int2str(b));
end
 
guidata(hObject,handles);</description>
		<content:encoded><![CDATA[<p>Doug,</p>
<p>   I try to use ButtonDownFcn to get information about image pixels in the current figure. The function works well before  the image showed in axes, but after the image loading into the axes, the ButtonDownFcn does not work. </p>
<p>here is the code</p>
<p>%%%%%<br />
function pushbutton_input_vimage_Callback(hObject, eventdata, handles)</p>
<p>[vname,vpath]=uigetfile(&#8217;*.bmp; *.img; *.jpg; *.tif&#8217;);<br />
vimage=[vpath vname];<br />
handles.user.plot_vimage=imread(vimage);</p>
<p>axes(handles.Visible_iamge)</p>
<p>image(handles.user.plot_vimage)</p>
<p>guidata(hObject, handles);</p>
<p>%%%%%<br />
function popupmenu_vpoints_Callback(hObject, eventdata, handles)</p>
<p>if get(hObject, &#8216;value&#8217;)==2<br />
   handles.mouse_track=2;</p>
<p>elseif get(hObject, &#8216;value&#8217;)==3<br />
     handles.mouse_track=3;</p>
<p>elseif get(hObject, &#8216;value&#8217;)==4<br />
     handles.mouse_track=4;</p>
<p>end</p>
<p>guidata(hObject, handles);</p>
<p>%%%%<br />
function Visible_iamge_ButtonDownFcn(hObject, eventdata, handles)<br />
handles.mouse_pos_fig=get(handles.figure1,&#8217;currentpoint&#8217;);<br />
axes_area=get(handles.Visible_iamge,&#8217;position&#8217;);</p>
<p>if (handles.mouse_pos_fig(1)(axes_area(1))) &amp;&amp; &#8230;<br />
        (handles.mouse_pos_fig(2)(axes_area(2)))<br />
    handles.mouse_pos=get(hObject,&#8217;currentpoint&#8217;);<br />
else<br />
    handles.mouse_pos=-1;<br />
end</p>
<p>b=handles.mouse_pos(1,1:2);</p>
<p>if handles.mouse_track==2<br />
    set(handles.text_A,&#8217;string&#8217;,int2str(b));<br />
elseif handles.mouse_track==3<br />
    set(handles.text_B,&#8217;string&#8217;,int2str(b));<br />
elseif handles.mouse_track==4<br />
    set(handles.text_C,&#8217;string&#8217;,int2str(b));<br />
end</p>
<p>guidata(hObject,handles);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug</title>
		<link>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13044</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Tue, 17 Feb 2009 18:11:43 +0000</pubDate>
		<guid>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13044</guid>
		<description>Zach,

I have done this kind of thing before, it does require some advanced maneuvers.  Mostly it is about using ASSIGNIN to redefine a variable in the workspace as you modify it graphically.  You need to place that function call in the end of the callback that modifies the data.

-Doug</description>
		<content:encoded><![CDATA[<p>Zach,</p>
<p>I have done this kind of thing before, it does require some advanced maneuvers.  Mostly it is about using ASSIGNIN to redefine a variable in the workspace as you modify it graphically.  You need to place that function call in the end of the callback that modifies the data.</p>
<p>-Doug</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zach</title>
		<link>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13043</link>
		<dc:creator>Zach</dc:creator>
		<pubDate>Tue, 17 Feb 2009 17:26:06 +0000</pubDate>
		<guid>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13043</guid>
		<description>How can this function/code be used to modify the data by dragging it?

If it cant be used to do this, then what function allows me to drag data points from a plot and modify the graph (and the new data) on the fly.

Thanks

Zach</description>
		<content:encoded><![CDATA[<p>How can this function/code be used to modify the data by dragging it?</p>
<p>If it cant be used to do this, then what function allows me to drag data points from a plot and modify the graph (and the new data) on the fly.</p>
<p>Thanks</p>
<p>Zach</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug</title>
		<link>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13037</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Fri, 13 Feb 2009 20:22:57 +0000</pubDate>
		<guid>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13037</guid>
		<description>CW,

'buttonDownFcn' is spelled wrong in the above code.

Doug</description>
		<content:encoded><![CDATA[<p>CW,</p>
<p>&#8216;buttonDownFcn&#8217; is spelled wrong in the above code.</p>
<p>Doug</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: CW</title>
		<link>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13036</link>
		<dc:creator>CW</dc:creator>
		<pubDate>Fri, 13 Feb 2009 13:38:28 +0000</pubDate>
		<guid>http://blogs.mathworks.com/pick/2007/12/26/advanced-matlab-buttondownfcn/#comment-13036</guid>
		<description>I am having problem replicating the great example you have provided here.  Specifically, I have create the following in an m file in an attempt to replicate what you have here...

function[] = graphinteract

figure(1)
plot(peaks)
set(gca,'buttondwnfcn', @clicker)

function clicker(gcbo,eventdata,handles)
disp(get(gca,'Currentpoint'))


However, I always get the following error...

??? There is no 'buttondwnfcn' property in the 'axes' class.

Error in ==&#62; graphinteract at 5
set(gca,'buttondwnfcn', @clicker)


Any idea what I am doing wrong?</description>
		<content:encoded><![CDATA[<p>I am having problem replicating the great example you have provided here.  Specifically, I have create the following in an m file in an attempt to replicate what you have here&#8230;</p>
<p>function[] = graphinteract</p>
<p>figure(1)<br />
plot(peaks)<br />
set(gca,&#8217;buttondwnfcn&#8217;, @clicker)</p>
<p>function clicker(gcbo,eventdata,handles)<br />
disp(get(gca,&#8217;Currentpoint&#8217;))</p>
<p>However, I always get the following error&#8230;</p>
<p>??? There is no &#8216;buttondwnfcn&#8217; property in the &#8216;axes&#8217; class.</p>
<p>Error in ==&gt; graphinteract at 5<br />
set(gca,&#8217;buttondwnfcn&#8217;, @clicker)</p>
<p>Any idea what I am doing wrong?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
