<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Uicontrol callbacks</title> <atom:link href="http://undocumentedmatlab.com/blog/uicontrol-callbacks/feed/" rel="self" type="application/rss+xml" /><link>http://undocumentedmatlab.com/blog/uicontrol-callbacks/</link> <description>Charting Matlab's unsupported hidden underbelly</description> <lastBuildDate>Fri, 03 Feb 2012 11:51:43 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.1.1</generator> <item><title>By: Matlab-Java memory leaks, performance &#124; Undocumented Matlab</title><link>http://undocumentedmatlab.com/blog/uicontrol-callbacks/#comment-71620</link> <dc:creator>Matlab-Java memory leaks, performance &#124; Undocumented Matlab</dc:creator> <pubDate>Fri, 20 Jan 2012 11:52:29 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=223#comment-71620</guid> <description>[...] a Matlab callback that gets invoked multiple times per second by a Java object (see related articles here and here). Each time the Matlab callback function is invoked, it reads the event information [...]</description> <content:encoded><![CDATA[<p>[...] a Matlab callback that gets invoked multiple times per second by a Java object (see related articles here and here). Each time the Matlab callback function is invoked, it reads the event information [...]</p> ]]></content:encoded> </item> <item><title>By: Yair Altman</title><link>http://undocumentedmatlab.com/blog/uicontrol-callbacks/#comment-69592</link> <dc:creator>Yair Altman</dc:creator> <pubDate>Thu, 05 Jan 2012 10:05:52 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=223#comment-69592</guid> <description>@Dave - this is correct. Matlab callbacks always send the originating object (in your case, a button which is actually an MJButton control) as the first parameter, and an eventData object as the second parameter. in eventData you can find information regarding the event, for example whether the button was clicked or right-clicked etc.</description> <content:encoded><![CDATA[<p>@Dave &#8211; this is correct. Matlab callbacks always send the originating object (in your case, a button which is actually an MJButton control) as the first parameter, and an eventData object as the second parameter. in eventData you can find information regarding the event, for example whether the button was clicked or right-clicked etc.</p> ]]></content:encoded> </item> <item><title>By: Dave</title><link>http://undocumentedmatlab.com/blog/uicontrol-callbacks/#comment-69244</link> <dc:creator>Dave</dc:creator> <pubDate>Tue, 03 Jan 2012 15:35:01 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=223#comment-69244</guid> <description>Yair, your knowledge is incredible, thank you for sharing.
Please excuse my lack of understanding but it seems that whenever I try to use a callback it sends &lt;i&gt;javahandle_withcallbacks.com.mathworks.mwswing.MJButton&lt;/i&gt; as the first parameter.
&lt;pre lang=&quot;matlab&quot;&gt;
function badprogrammingpracticehFig = figure(&#039;position&#039;, [300 300 600 400]);
jbt = com.mathworks.mwswing.MJButton(&#039;click me&#039;);
jbt.setBorder([])
jbt.setBackground(java.awt.Color.white);
jbt.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.HAND_CURSOR));
jbt.setFlyOverAppearance(1);
bob = [1 2 3]
jbtPosition = [0.1 0.1 0.3 0.3]
[dummy,btContainer] = javacomponent(jbt,[0 0 1 1],hFig);
set(btContainer, &#039;Units&#039;,&#039;Norm&#039;, &#039;Position&#039;,jbtPosition);
hbt = handle(jbt,&#039;CallbackProperties&#039;);
set(hbt,&#039;ActionPerformedCallback&#039;,@dosomething);function [mean,stdev] = dosomething(x,y)
x
&lt;/pre&gt;output:bob =
1     2     3
jbtPosition =
0.1000    0.1000    0.3000    0.3000
x =
javahandle_withcallbacks.com.mathworks.mwswing.MJButton
&gt;&gt;</description> <content:encoded><![CDATA[<p>Yair, your knowledge is incredible, thank you for sharing.<br
/> Please excuse my lack of understanding but it seems that whenever I try to use a callback it sends <i>javahandle_withcallbacks.com.mathworks.mwswing.MJButton</i> as the first parameter.</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">function</span> badprogrammingpractice
&nbsp;
hFig = <span style="color: #0000FF;">figure</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'position'</span>, <span style="color: #080;">&#91;</span><span style="color: #33f;">300</span> <span style="color: #33f;">300</span> <span style="color: #33f;">600</span> <span style="color: #33f;">400</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>;
jbt = com.<span style="">mathworks</span>.<span style="">mwswing</span>.<span style="">MJButton</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'click me'</span><span style="color: #080;">&#41;</span>;
jbt.<span style="">setBorder</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>
jbt.<span style="">setBackground</span><span style="color: #080;">&#40;</span>java.<span style="">awt</span>.<span style="">Color</span>.<span style="">white</span><span style="color: #080;">&#41;</span>;
jbt.<span style="">setCursor</span><span style="color: #080;">&#40;</span>java.<span style="">awt</span>.<span style="">Cursor</span>.<span style="">getPredefinedCursor</span><span style="color: #080;">&#40;</span>java.<span style="">awt</span>.<span style="">Cursor</span>.<span style="">HAND_CURSOR</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
jbt.<span style="">setFlyOverAppearance</span><span style="color: #080;">&#40;</span><span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>;
bob = <span style="color: #080;">&#91;</span><span style="color: #33f;">1</span> <span style="color: #33f;">2</span> <span style="color: #33f;">3</span><span style="color: #080;">&#93;</span>
jbtPosition = <span style="color: #080;">&#91;</span><span style="color: #33f;">0.1</span> <span style="color: #33f;">0.1</span> <span style="color: #33f;">0.3</span> <span style="color: #33f;">0.3</span><span style="color: #080;">&#93;</span>
<span style="color: #080;">&#91;</span>dummy,btContainer<span style="color: #080;">&#93;</span> = javacomponent<span style="color: #080;">&#40;</span>jbt,<span style="color: #080;">&#91;</span><span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">1</span> <span style="color: #33f;">1</span><span style="color: #080;">&#93;</span>,hFig<span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>btContainer, <span style="color:#A020F0;">'Units'</span>,<span style="color:#A020F0;">'Norm'</span>, <span style="color:#A020F0;">'Position'</span>,jbtPosition<span style="color: #080;">&#41;</span>;
hbt = handle<span style="color: #080;">&#40;</span>jbt,<span style="color:#A020F0;">'CallbackProperties'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>hbt,<span style="color:#A020F0;">'ActionPerformedCallback'</span>,@dosomething<span style="color: #080;">&#41;</span>;
&nbsp;
<span style="color: #0000FF;">function</span> <span style="color: #080;">&#91;</span><span style="color: #0000FF;">mean</span>,stdev<span style="color: #080;">&#93;</span> = dosomething<span style="color: #080;">&#40;</span>x,y<span style="color: #080;">&#41;</span>
x</pre></div></div><p>output:</p><p>bob =<br
/> 1     2     3<br
/> jbtPosition =<br
/> 0.1000    0.1000    0.3000    0.3000<br
/> x =<br
/> javahandle_withcallbacks.com.mathworks.mwswing.MJButton<br
/> &gt;&gt;</p> ]]></content:encoded> </item> <item><title>By: Janos Marki</title><link>http://undocumentedmatlab.com/blog/uicontrol-callbacks/#comment-31631</link> <dc:creator>Janos Marki</dc:creator> <pubDate>Sun, 30 Jan 2011 14:27:16 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=223#comment-31631</guid> <description>Update to previous: it now works. I think the problem was with the callback getting overwritten for some reason (only possible culprit: pcolor function). By inserting the callback handle again, it works without a hitch. Sorry for the hassle.Janos&lt;pre lang=&quot;matlab&quot;&gt;
figure(a111)
set(gcf,&#039;WindowKeyPressFcn&#039;,@scalSet)
waitfor(a111,&#039;UserData&#039;,&#039;Done&#039;);
&lt;/pre&gt;</description> <content:encoded><![CDATA[<p>Update to previous: it now works. I think the problem was with the callback getting overwritten for some reason (only possible culprit: pcolor function). By inserting the callback handle again, it works without a hitch. Sorry for the hassle.</p><p>Janos</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">figure</span><span style="color: #080;">&#40;</span>a111<span style="color: #080;">&#41;</span>
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span>,<span style="color:#A020F0;">'WindowKeyPressFcn'</span>,@scalSet<span style="color: #080;">&#41;</span>
waitfor<span style="color: #080;">&#40;</span>a111,<span style="color:#A020F0;">'UserData'</span>,<span style="color:#A020F0;">'Done'</span><span style="color: #080;">&#41;</span>;</pre></div></div>]]></content:encoded> </item> <item><title>By: Janos Marki</title><link>http://undocumentedmatlab.com/blog/uicontrol-callbacks/#comment-31614</link> <dc:creator>Janos Marki</dc:creator> <pubDate>Sun, 30 Jan 2011 12:12:49 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=223#comment-31614</guid> <description>Hi,I have a problem that I can&#039;t seem to solve, and I can&#039;t find the info.I execute a number of commands culminating in a plot. At this point, I need to intervene manually, which I thought of doing via the WindowKeyPressFcn callback of the figure I plotted in. Once done, I would like script execution to resume.However, whatever way I use to stop keyboard execution (keyboard, waitfor(figHand), no matter what I do, instead of the figure&#039;s callback (scalSet.m) activating, the pressed key appears in the command window (i.e. I cannot make the figure the &quot;active&quot; object so the pressed key goes into it). It seems to me like this goes against the notion of having ready code, running the GUI, and then interacting with it (as interaction would already start whilst the script is run). Is this me trying to use Matlab in ways it has not been intended to work? Can it be done, or should I just do it differently?&lt;pre lang=&quot;matlab&quot;&gt;
a111=figure(&#039;WindowKeyPressFcn&#039;,@scalSet);
waitfor(a111,&#039;UserData&#039;,&#039;Done&#039;);
&lt;/pre&gt;
...and the idea was to have one key (d) for the &quot;Done&quot; state in the callback function (waitfor would let the script carry on once this is triggered), which looks like this:
&lt;pre lang=&quot;matlab&quot;&gt;
function scalSet(src,eventdata)
%function scalSet(src,eventdata)
%
%Function used to set scales with the mouse manually on plots with a colorbar
%Press &#039;r&#039; to narrow the scale by clicking two values on the
%colorbar with the mouse
%
%Press &#039;w&#039; to double the range
%
%enter set(gcf,&#039;WindowKeyPressFcn&#039;,@scalSet) to add it to figures a
%posteriori%we want to make the colorbar scaling smaller
if strcmp(eventdata.Character,&#039;r&#039;)
scval=ginput(2);
chs=get(src,&#039;Children&#039;);
for k=1:length(chs)
nu=get(chs(k),&#039;Type&#039;);
if strcmp(nu,&#039;axes&#039;)
nu2=get(chs(k),&#039;Tag&#039;);
if ~strcmp(nu2,&#039;Colorbar&#039;)
caxis(chs(k),[sort(scval(:,2))&#039;])
end
end
end
end%we want to widen it
if strcmp(eventdata.Character,&#039;w&#039;)
scval=caxis;
wid=scval(2)-scval(1);
caxis([scval(1)-wid scval(2)+wid])
end%we are done
if strcmp(eventdata.Character,&#039;d&#039;)
set(src,&#039;UserData&#039;,&#039;Done&#039;)
end
&lt;/pre&gt;Thanks!
Janos</description> <content:encoded><![CDATA[<p>Hi,</p><p>I have a problem that I can&#8217;t seem to solve, and I can&#8217;t find the info.</p><p>I execute a number of commands culminating in a plot. At this point, I need to intervene manually, which I thought of doing via the WindowKeyPressFcn callback of the figure I plotted in. Once done, I would like script execution to resume.</p><p>However, whatever way I use to stop keyboard execution (keyboard, waitfor(figHand), no matter what I do, instead of the figure&#8217;s callback (scalSet.m) activating, the pressed key appears in the command window (i.e. I cannot make the figure the &#8220;active&#8221; object so the pressed key goes into it). It seems to me like this goes against the notion of having ready code, running the GUI, and then interacting with it (as interaction would already start whilst the script is run). Is this me trying to use Matlab in ways it has not been intended to work? Can it be done, or should I just do it differently?</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">a111=<span style="color: #0000FF;">figure</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'WindowKeyPressFcn'</span>,@scalSet<span style="color: #080;">&#41;</span>; 
waitfor<span style="color: #080;">&#40;</span>a111,<span style="color:#A020F0;">'UserData'</span>,<span style="color:#A020F0;">'Done'</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>&#8230;and the idea was to have one key (d) for the &#8220;Done&#8221; state in the callback function (waitfor would let the script carry on once this is triggered), which looks like this:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">function</span> scalSet<span style="color: #080;">&#40;</span>src,eventdata<span style="color: #080;">&#41;</span>
<span style="color: #228B22;">%function scalSet(src,eventdata)</span>
<span style="color: #228B22;">%</span>
<span style="color: #228B22;">%Function used to set scales with the mouse manually on plots with a colorbar</span>
<span style="color: #228B22;">%Press 'r' to narrow the scale by clicking two values on the</span>
<span style="color: #228B22;">%colorbar with the mouse</span>
<span style="color: #228B22;">%</span>
<span style="color: #228B22;">%Press 'w' to double the range</span>
<span style="color: #228B22;">%</span>
<span style="color: #228B22;">%enter set(gcf,'WindowKeyPressFcn',@scalSet) to add it to figures a</span>
<span style="color: #228B22;">%posteriori</span>
&nbsp;
<span style="color: #228B22;">%we want to make the colorbar scaling smaller</span>
<span style="color: #0000FF;">if</span> <span style="color: #0000FF;">strcmp</span><span style="color: #080;">&#40;</span>eventdata.<span style="">Character</span>,<span style="color:#A020F0;">'r'</span><span style="color: #080;">&#41;</span>
   scval=<span style="color: #0000FF;">ginput</span><span style="color: #080;">&#40;</span><span style="color: #33f;">2</span><span style="color: #080;">&#41;</span>;
   chs=<span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>src,<span style="color:#A020F0;">'Children'</span><span style="color: #080;">&#41;</span>;
   <span style="color: #0000FF;">for</span> k=<span style="color: #33f;">1</span><span style="color: #F0F;">:</span><span style="color: #0000FF;">length</span><span style="color: #080;">&#40;</span>chs<span style="color: #080;">&#41;</span>
       nu=<span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>chs<span style="color: #080;">&#40;</span>k<span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'Type'</span><span style="color: #080;">&#41;</span>;
       <span style="color: #0000FF;">if</span> <span style="color: #0000FF;">strcmp</span><span style="color: #080;">&#40;</span>nu,<span style="color:#A020F0;">'axes'</span><span style="color: #080;">&#41;</span>
         nu2=<span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>chs<span style="color: #080;">&#40;</span>k<span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'Tag'</span><span style="color: #080;">&#41;</span>;
           <span style="color: #0000FF;">if</span> ~<span style="color: #0000FF;">strcmp</span><span style="color: #080;">&#40;</span>nu2,<span style="color:#A020F0;">'Colorbar'</span><span style="color: #080;">&#41;</span>
               <span style="color: #0000FF;">caxis</span><span style="color: #080;">&#40;</span>chs<span style="color: #080;">&#40;</span>k<span style="color: #080;">&#41;</span>,<span style="color: #080;">&#91;</span><span style="color: #0000FF;">sort</span><span style="color: #080;">&#40;</span>scval<span style="color: #080;">&#40;</span><span style="color: #F0F;">:</span>,<span style="color: #33f;">2</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>'<span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>
           <span style="color: #0000FF;">end</span>
       <span style="color: #0000FF;">end</span>
   <span style="color: #0000FF;">end</span>   
<span style="color: #0000FF;">end</span>
&nbsp;
<span style="color: #228B22;">%we want to widen it</span>
<span style="color: #0000FF;">if</span> <span style="color: #0000FF;">strcmp</span><span style="color: #080;">&#40;</span>eventdata.<span style="">Character</span>,<span style="color:#A020F0;">'w'</span><span style="color: #080;">&#41;</span>
   scval=<span style="color: #0000FF;">caxis</span>;
   wid=scval<span style="color: #080;">&#40;</span><span style="color: #33f;">2</span><span style="color: #080;">&#41;</span>-scval<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>;
   <span style="color: #0000FF;">caxis</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#91;</span>scval<span style="color: #080;">&#40;</span><span style="color: #33f;">1</span><span style="color: #080;">&#41;</span>-wid scval<span style="color: #080;">&#40;</span><span style="color: #33f;">2</span><span style="color: #080;">&#41;</span>+wid<span style="color: #080;">&#93;</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF;">end</span>
&nbsp;
<span style="color: #228B22;">%we are done</span>
<span style="color: #0000FF;">if</span> <span style="color: #0000FF;">strcmp</span><span style="color: #080;">&#40;</span>eventdata.<span style="">Character</span>,<span style="color:#A020F0;">'d'</span><span style="color: #080;">&#41;</span>
   <span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>src,<span style="color:#A020F0;">'UserData'</span>,<span style="color:#A020F0;">'Done'</span><span style="color: #080;">&#41;</span> 
<span style="color: #0000FF;">end</span></pre></div></div><p>Thanks!<br
/> Janos</p> ]]></content:encoded> </item> <item><title>By: Yair Altman</title><link>http://undocumentedmatlab.com/blog/uicontrol-callbacks/#comment-24937</link> <dc:creator>Yair Altman</dc:creator> <pubDate>Tue, 07 Dec 2010 19:59:06 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=223#comment-24937</guid> <description>@Sean - take a look at: http://undocumentedmatlab.com/blog/modifying-default-toolbar-menubar-actions/Related articles:
http://undocumentedmatlab.com/blog/figure-toolbar-components/
http://undocumentedmatlab.com/blog/figure-toolbar-customizations/- Yair</description> <content:encoded><![CDATA[<p>@Sean &#8211; take a look at: <a
href="http://undocumentedmatlab.com/blog/modifying-default-toolbar-menubar-actions/" rel="nofollow">http://undocumentedmatlab.com/blog/modifying-default-toolbar-menubar-actions/</a></p><p>Related articles:<br
/> <a
href="http://undocumentedmatlab.com/blog/figure-toolbar-components/" rel="nofollow">http://undocumentedmatlab.com/blog/figure-toolbar-components/</a><br
/> <a
href="http://undocumentedmatlab.com/blog/figure-toolbar-customizations/" rel="nofollow">http://undocumentedmatlab.com/blog/figure-toolbar-customizations/</a></p><p>- Yair</p> ]]></content:encoded> </item> <item><title>By: Sean Larkin</title><link>http://undocumentedmatlab.com/blog/uicontrol-callbacks/#comment-24931</link> <dc:creator>Sean Larkin</dc:creator> <pubDate>Tue, 07 Dec 2010 19:12:07 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=223#comment-24931</guid> <description>I&#039;m trying to use findjobj to get the java handle for a toolbar uitogglebutton.  It does not find the handles for the button.  When I call the function like this:
findjobj;it finds the toolbar button.  Why is this and is there a way I can modify findjobj to directly find toolbar buttons?</description> <content:encoded><![CDATA[<p>I&#8217;m trying to use findjobj to get the java handle for a toolbar uitogglebutton.  It does not find the handles for the button.  When I call the function like this:<br
/> findjobj;</p><p>it finds the toolbar button.  Why is this and is there a way I can modify findjobj to directly find toolbar buttons?</p> ]]></content:encoded> </item> <item><title>By: iroln</title><link>http://undocumentedmatlab.com/blog/uicontrol-callbacks/#comment-22396</link> <dc:creator>iroln</dc:creator> <pubDate>Wed, 10 Nov 2010 21:11:15 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=223#comment-22396</guid> <description>Thanks, Yair Altman!</description> <content:encoded><![CDATA[<p>Thanks, Yair Altman!</p> ]]></content:encoded> </item> <item><title>By: Yair Altman</title><link>http://undocumentedmatlab.com/blog/uicontrol-callbacks/#comment-22139</link> <dc:creator>Yair Altman</dc:creator> <pubDate>Sun, 07 Nov 2010 22:40:23 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=223#comment-22139</guid> <description>@iroln and Donn - apparently all mouse actions are delegated to the AxisCanvas component, so simply set your callback on that component. It works for me on R2010b. Here&#039;s the complete code snippet:
&lt;pre lang=&quot;matlab&quot;&gt;
function TestMouseCallbacks()
hFig = figure();
warning(&#039;off&#039;,&#039;MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame&#039;);
drawnow;
jh = get(hFig, &#039;JavaFrame&#039;);
jf = jh.fFigureClient.getAxisComponent;  % note the change
jbh = handle(jf, &#039;CallbackProperties&#039;);
set(jbh, &#039;MouseWheelMovedCallback&#039;, @MousePressed)
end
function MousePressed(jObject, jEventData)
disp(&#039;Pressed&#039;)
end
&lt;/pre&gt;</description> <content:encoded><![CDATA[<p>@iroln and Donn &#8211; apparently all mouse actions are delegated to the AxisCanvas component, so simply set your callback on that component. It works for me on R2010b. Here&#8217;s the complete code snippet:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">function</span> TestMouseCallbacks<span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>
  hFig = <span style="color: #0000FF;">figure</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#41;</span>;
  <span style="color: #0000FF;">warning</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'off'</span>,<span style="color:#A020F0;">'MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame'</span><span style="color: #080;">&#41;</span>;
  <span style="color: #0000FF;">drawnow</span>;
  jh = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>hFig, <span style="color:#A020F0;">'JavaFrame'</span><span style="color: #080;">&#41;</span>;
  jf = jh.<span style="">fFigureClient</span>.<span style="">getAxisComponent</span>;  <span style="color: #228B22;">% note the change</span>
  jbh = handle<span style="color: #080;">&#40;</span>jf, <span style="color:#A020F0;">'CallbackProperties'</span><span style="color: #080;">&#41;</span>;
  <span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>jbh, <span style="color:#A020F0;">'MouseWheelMovedCallback'</span>, @MousePressed<span style="color: #080;">&#41;</span>
<span style="color: #0000FF;">end</span>
&nbsp;
<span style="color: #0000FF;">function</span> MousePressed<span style="color: #080;">&#40;</span>jObject, jEventData<span style="color: #080;">&#41;</span>
  <span style="color: #0000FF;">disp</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Pressed'</span><span style="color: #080;">&#41;</span>
<span style="color: #0000FF;">end</span></pre></div></div>]]></content:encoded> </item> <item><title>By: Donn Shull</title><link>http://undocumentedmatlab.com/blog/uicontrol-callbacks/#comment-21952</link> <dc:creator>Donn Shull</dc:creator> <pubDate>Fri, 05 Nov 2010 15:53:09 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=223#comment-21952</guid> <description>@iroln – I am using windows 7 32 bit and the code you just sent works  as you described</description> <content:encoded><![CDATA[<p>@iroln – I am using windows 7 32 bit and the code you just sent works  as you described</p> ]]></content:encoded> </item> </channel> </rss>

<!-- W3 Total Cache: Minify debug info:
Engine:             disk: basic
Theme:              b7666
Template:           single
-->
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: undocumentedmatlab.com @ 2012-02-04 03:58:24 -->

<!-- W3 Total Cache: Page cache debug info:
Engine:             disk: enhanced
Cache key:          blog/uicontrol-callbacks/feed/_index.xml_gzip
Caching:            enabled
Status:             not cached
Creation Time:      0.740s
Header info:
X-Pingback:         http://undocumentedmatlab.com/blog/xmlrpc.php
Set-Cookie:         wpgb_visit_last_php-default=1328353104; expires=Sun, 03-Feb-2013 10:58:24 GMT; path=/
Link:               <http://undocumentedmatlab.com/?p=223>; rel=shortlink
Content-Type:       text/xml; charset=UTF-8
Last-Modified:      Sat, 04 Feb 2012 10:58:24 GMT
Vary:               Accept-Encoding, Cookie
Expires:            Sat, 04 Feb 2012 11:58:24 GMT
Pragma:             public
Cache-Control:      public, must-revalidate, proxy-revalidate
Etag:               8a9f8f7ca3f6c815f6e29a0cd2c2d67c
Content-Encoding:   gzip
-->
