<?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: Figure toolbar components</title> <atom:link href="http://undocumentedmatlab.com/blog/figure-toolbar-components/feed/" rel="self" type="application/rss+xml" /><link>http://undocumentedmatlab.com/blog/figure-toolbar-components/</link> <description>Charting Matlab's unsupported hidden underbelly</description> <lastBuildDate>Thu, 09 Feb 2012 09:23:08 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.1.1</generator> <item><title>By: Kesh</title><link>http://undocumentedmatlab.com/blog/figure-toolbar-components/#comment-13978</link> <dc:creator>Kesh</dc:creator> <pubDate>Fri, 30 Jul 2010 15:01:27 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=541#comment-13978</guid> <description>Yair,Actually, I thought of that right after I posted yesterday so I did some more testing and found out that the behavior of a Matlab uicontrol popupmenu is indeed what I expect. For example, create a figure with a uicontrol popupmenu and enable both its callback and figure&#039;s keypressfcn:&lt;pre lang=&quot;matlab&quot;&gt;
uicontrol(&#039;style&#039;,&#039;popupmenu&#039;,&#039;string&#039;,{&#039;1&#039;,&#039;2&#039;,&#039;3&#039;},&#039;Callback&#039;,&#039;disp(&#039;&#039;popupmenu callback&#039;&#039;)&#039;);
set(gcf,&#039;WindowKeyPressFcn&#039;,&#039;disp(&#039;&#039;windowskeypressfcn&#039;&#039;)&#039;);
&lt;/pre&gt;Then, when you put focus on the popupmenu and press &quot;1&quot; key, Matlab prints:&lt;pre lang=&quot;matlab&quot;&gt;
popupmenu callback
windowskeypressfcn
&lt;/pre&gt;I believe I found the fix. Simply the same KeyPress callback function can be assigned to the Java combo-box&#039;s KeyPressCallback.Thanks for your tips and great blog!!</description> <content:encoded><![CDATA[<p>Yair,</p><p>Actually, I thought of that right after I posted yesterday so I did some more testing and found out that the behavior of a Matlab uicontrol popupmenu is indeed what I expect. For example, create a figure with a uicontrol popupmenu and enable both its callback and figure&#8217;s keypressfcn:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">uicontrol</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'style'</span>,<span style="color:#A020F0;">'popupmenu'</span>,<span style="color:#A020F0;">'string'</span>,<span style="color: #080;">&#123;</span><span style="color:#A020F0;">'1'</span>,<span style="color:#A020F0;">'2'</span>,<span style="color:#A020F0;">'3'</span><span style="color: #080;">&#125;</span>,<span style="color:#A020F0;">'Callback'</span>,<span style="color:#A020F0;">'disp('</span><span style="color:#A020F0;">'popupmenu callback'</span><span style="color:#A020F0;">')'</span><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>,<span style="color:#A020F0;">'disp('</span><span style="color:#A020F0;">'windowskeypressfcn'</span><span style="color:#A020F0;">')'</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>Then, when you put focus on the popupmenu and press &#8220;1&#8243; key, Matlab prints:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">popupmenu callback
windowskeypressfcn</pre></div></div><p>I believe I found the fix. Simply the same KeyPress callback function can be assigned to the Java combo-box&#8217;s KeyPressCallback.</p><p>Thanks for your tips and great blog!!</p> ]]></content:encoded> </item> <item><title>By: Yair Altman</title><link>http://undocumentedmatlab.com/blog/figure-toolbar-components/#comment-13954</link> <dc:creator>Yair Altman</dc:creator> <pubDate>Fri, 30 Jul 2010 06:44:41 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=541#comment-13954</guid> <description>@Kesh - this is actually the expected behavior: the combo-box &quot;consumes&quot; the keyboard event and so the figure window is not aware that an event has occurred. Change your combo-box items to {&#039;1&#039;,&#039;2&#039;,&#039;3&#039;,&#039;4&#039;} and then click 1,4,3,2 to see that the combo-box moves the selection to the next relevant entry. It is really quite intuitive once you see it.BTW, the combo-box keyboard listeners can be removed, but I strongly suggest to NOT do it, since it will also prevent using the arrow keys etc. Moreover, many users will actually expect the regular behavior.</description> <content:encoded><![CDATA[<p>@Kesh &#8211; this is actually the expected behavior: the combo-box &#8220;consumes&#8221; the keyboard event and so the figure window is not aware that an event has occurred. Change your combo-box items to {&#8217;1&#8242;,&#8217;2&#8242;,&#8217;3&#8242;,&#8217;4&#8242;} and then click 1,4,3,2 to see that the combo-box moves the selection to the next relevant entry. It is really quite intuitive once you see it.</p><p>BTW, the combo-box keyboard listeners can be removed, but I strongly suggest to NOT do it, since it will also prevent using the arrow keys etc. Moreover, many users will actually expect the regular behavior.</p> ]]></content:encoded> </item> <item><title>By: Kesh</title><link>http://undocumentedmatlab.com/blog/figure-toolbar-components/#comment-13924</link> <dc:creator>Kesh</dc:creator> <pubDate>Thu, 29 Jul 2010 22:35:48 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=541#comment-13924</guid> <description>@Yair - Brilliant solution!I have another little annoyance that I&#039;d love to get rid of. It&#039;s a focus-related issue with JComboBox (I suspect it&#039;s more than JcomboBox specific and applies to all Java GUI Components).Here&#039;s an example:&lt;pre lang=&quot;matlab&quot;&gt;
fig = figure;
set(fig,&#039;WindowKeyPressFcn&#039;,&#039;disp(&#039;&#039;1&#039;&#039;)&#039;);
tb = uitoolbar;
drawnow
jToolbar = get(get(tb,&#039;JavaContainer&#039;),&#039;ComponentPeer&#039;);
jCombo = javax.swing.JComboBox({&#039;Test Item 1&#039;,&#039;Test Item 2&#039;});
jToolbar.add(jCombo);
jToolbar.repaint;
jToolbar.revalidate;
&lt;/pre&gt;WindowsKeyPressFcn is supposed to display &quot;1&quot; in Command Window if a key is pressed anytime when the figure is on top. However, clicking on JComboBox causes WindowsKeyPressFcn to be not called until another part of the figure is clicked.I&#039;m guessing that this behavior comes from the fact that the figure window control has been passed on from Matlab to Java when JComboBox gets the focus; thus, Matlab callback events are no longer happening.I&#039;m currently using java.awt.Robot.mousePress to force the control back to Matlab. It works, but I&#039;m wondering if there is a better solution (Can we mess with Java Focus Manager?).Any ideas?</description> <content:encoded><![CDATA[<p>@Yair &#8211; Brilliant solution!</p><p>I have another little annoyance that I&#8217;d love to get rid of. It&#8217;s a focus-related issue with JComboBox (I suspect it&#8217;s more than JcomboBox specific and applies to all Java GUI Components).</p><p>Here&#8217;s an example:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">fig = <span style="color: #0000FF;">figure</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span>fig,<span style="color:#A020F0;">'WindowKeyPressFcn'</span>,<span style="color:#A020F0;">'disp('</span><span style="color:#A020F0;">'1'</span><span style="color:#A020F0;">')'</span><span style="color: #080;">&#41;</span>;
tb = uitoolbar;
<span style="color: #0000FF;">drawnow</span>
jToolbar = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>tb,<span style="color:#A020F0;">'JavaContainer'</span><span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'ComponentPeer'</span><span style="color: #080;">&#41;</span>;
jCombo = javax.<span style="">swing</span>.<span style="">JComboBox</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#123;</span><span style="color:#A020F0;">'Test Item 1'</span>,<span style="color:#A020F0;">'Test Item 2'</span><span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span>;
jToolbar.<span style="">add</span><span style="color: #080;">&#40;</span>jCombo<span style="color: #080;">&#41;</span>;
jToolbar.<span style="">repaint</span>;
jToolbar.<span style="">revalidate</span>;</pre></div></div><p>WindowsKeyPressFcn is supposed to display &#8220;1&#8243; in Command Window if a key is pressed anytime when the figure is on top. However, clicking on JComboBox causes WindowsKeyPressFcn to be not called until another part of the figure is clicked.</p><p>I&#8217;m guessing that this behavior comes from the fact that the figure window control has been passed on from Matlab to Java when JComboBox gets the focus; thus, Matlab callback events are no longer happening.</p><p>I&#8217;m currently using java.awt.Robot.mousePress to force the control back to Matlab. It works, but I&#8217;m wondering if there is a better solution (Can we mess with Java Focus Manager?).</p><p>Any ideas?</p> ]]></content:encoded> </item> <item><title>By: Yair Altman</title><link>http://undocumentedmatlab.com/blog/figure-toolbar-components/#comment-13897</link> <dc:creator>Yair Altman</dc:creator> <pubDate>Thu, 29 Jul 2010 16:01:27 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=541#comment-13897</guid> <description>@Kesh - good point. Java toolbar customizations are not stored in the saved FIG files. However, you can place your code in the figure&#039;s &lt;b&gt;CreateFcn&lt;/b&gt; property, and it will automatically get executed whenever the figure is reloaded from disk:&lt;pre lang=&quot;matlab&quot;&gt;
codeStr = [&#039;tb=uitoolbar;&#039; ...
&#039;drawnow;&#039; ...
&#039;jToolbar=get(get(tb,&#039;&#039;JavaContainer&#039;&#039;),&#039;&#039;ComponentPeer&#039;&#039;);&#039; ...
&#039;jCombo=javax.swing.JComboBox({&#039;&#039;Item 1&#039;&#039;,&#039;&#039;Item 2&#039;&#039;});&#039; ...
&#039;jToolbar.add(jCombo);&#039; ...
&#039;jToolbar.repaint;&#039; ...
&#039;jToolbar.revalidate;&#039;];
set(gcf,&#039;CreateFcn&#039;,codeStr)
hgsave(&#039;test&#039;);
eval(codeStr);  % display the new toolbarhgload(&#039;test&#039;);
&lt;/pre&gt;</description> <content:encoded><![CDATA[<p>@Kesh &#8211; good point. Java toolbar customizations are not stored in the saved FIG files. However, you can place your code in the figure&#8217;s <b>CreateFcn</b> property, and it will automatically get executed whenever the figure is reloaded from disk:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">codeStr = <span style="color: #080;">&#91;</span><span style="color:#A020F0;">'tb=uitoolbar;'</span> <span style="color: #F0F;">...</span>
           <span style="color:#A020F0;">'drawnow;'</span> <span style="color: #F0F;">...</span>
           <span style="color:#A020F0;">'jToolbar=get(get(tb,'</span><span style="color:#A020F0;">'JavaContainer'</span><span style="color:#A020F0;">'),'</span><span style="color:#A020F0;">'ComponentPeer'</span><span style="color:#A020F0;">');'</span> <span style="color: #F0F;">...</span>
           <span style="color:#A020F0;">'jCombo=javax.swing.JComboBox({'</span><span style="color:#A020F0;">'Item 1'</span><span style="color:#A020F0;">','</span><span style="color:#A020F0;">'Item 2'</span><span style="color:#A020F0;">'});'</span> <span style="color: #F0F;">...</span>
           <span style="color:#A020F0;">'jToolbar.add(jCombo);'</span> <span style="color: #F0F;">...</span>
           <span style="color:#A020F0;">'jToolbar.repaint;'</span> <span style="color: #F0F;">...</span>
           <span style="color:#A020F0;">'jToolbar.revalidate;'</span><span style="color: #080;">&#93;</span>;
<span style="color: #0000FF;">set</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">gcf</span>,<span style="color:#A020F0;">'CreateFcn'</span>,codeStr<span style="color: #080;">&#41;</span>
hgsave<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'test'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">eval</span><span style="color: #080;">&#40;</span>codeStr<span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% display the new toolbar</span>
&nbsp;
hgload<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'test'</span><span style="color: #080;">&#41;</span>;</pre></div></div>]]></content:encoded> </item> <item><title>By: Kesh</title><link>http://undocumentedmatlab.com/blog/figure-toolbar-components/#comment-13890</link> <dc:creator>Kesh</dc:creator> <pubDate>Thu, 29 Jul 2010 14:38:19 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=541#comment-13890</guid> <description>Yair,Good stuff! I&#039;ve been always wondered about the possibility of adding popupmenu to a uitoolbar. I do have a question though.I found if you save a figure (either via GUI or via hgsave) with added JComboBox toolbar component, the JComboBox is not saved. Do you know of any workaround to save java components to a .FIG file?Here&#039;s a quick example:Let say we created a figure with a popupmenu toolbar:&lt;pre lang=&quot;matlab&quot;&gt;
fig = figure;
tb = uitoolbar;
drawnow
jToolbar = get(get(tb,&#039;JavaContainer&#039;),&#039;ComponentPeer&#039;);
jCombo = javax.swing.JComboBox({&#039;Test Item 1&#039;,&#039;Test Item 2&#039;});
jToolbar.add(jCombo);
jToolbar.repaint;
jToolbar.revalidate;hgsave(&#039;test&#039;);
hgload(&#039;test&#039;);
&lt;/pre&gt;TIA!</description> <content:encoded><![CDATA[<p>Yair,</p><p>Good stuff! I&#8217;ve been always wondered about the possibility of adding popupmenu to a uitoolbar. I do have a question though.</p><p>I found if you save a figure (either via GUI or via hgsave) with added JComboBox toolbar component, the JComboBox is not saved. Do you know of any workaround to save java components to a .FIG file?</p><p>Here&#8217;s a quick example:</p><p>Let say we created a figure with a popupmenu toolbar:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">fig = <span style="color: #0000FF;">figure</span>;
tb = uitoolbar;
<span style="color: #0000FF;">drawnow</span>
jToolbar = <span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">get</span><span style="color: #080;">&#40;</span>tb,<span style="color:#A020F0;">'JavaContainer'</span><span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'ComponentPeer'</span><span style="color: #080;">&#41;</span>;
jCombo = javax.<span style="">swing</span>.<span style="">JComboBox</span><span style="color: #080;">&#40;</span><span style="color: #080;">&#123;</span><span style="color:#A020F0;">'Test Item 1'</span>,<span style="color:#A020F0;">'Test Item 2'</span><span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span>;
jToolbar.<span style="">add</span><span style="color: #080;">&#40;</span>jCombo<span style="color: #080;">&#41;</span>;
jToolbar.<span style="">repaint</span>;
jToolbar.<span style="">revalidate</span>;
&nbsp;
hgsave<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'test'</span><span style="color: #080;">&#41;</span>;
hgload<span style="color: #080;">&#40;</span><span style="color:#A020F0;">'test'</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>TIA!</p> ]]></content:encoded> </item> <item><title>By: uiundo – Matlab’s undocumented undo/redo manager &#124; Undocumented Matlab</title><link>http://undocumentedmatlab.com/blog/figure-toolbar-components/#comment-11420</link> <dc:creator>uiundo – Matlab’s undocumented undo/redo manager &#124; Undocumented Matlab</dc:creator> <pubDate>Wed, 23 Jun 2010 10:04:39 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=541#comment-11420</guid> <description>[...] A couple of months ago, I explained how to customize the figure toolbar. In that article, I used the undocumented &lt;i&gt;&lt;b&gt;uiundo&lt;/b&gt;&lt;/i&gt; function as a target for the toolbar customization [...]</description> <content:encoded><![CDATA[<p>[...] A couple of months ago, I explained how to customize the figure toolbar. In that article, I used the undocumented <i><b>uiundo</b></i> function as a target for the toolbar customization [...]</p> ]]></content:encoded> </item> <item><title>By: Modifying default toolbar/menubar actions &#124; Undocumented Matlab</title><link>http://undocumentedmatlab.com/blog/figure-toolbar-components/#comment-10645</link> <dc:creator>Modifying default toolbar/menubar actions &#124; Undocumented Matlab</dc:creator> <pubDate>Wed, 02 Jun 2010 14:08:32 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=541#comment-10645</guid> <description>[...] Examples of toolbar customizations were presented in past articles (here and here). A future article will explain how to customize menu [...]</description> <content:encoded><![CDATA[<p>[...] Examples of toolbar customizations were presented in past articles (here and here). A future article will explain how to customize menu [...]</p> ]]></content:encoded> </item> <item><title>By: Yair Altman</title><link>http://undocumentedmatlab.com/blog/figure-toolbar-components/#comment-7603</link> <dc:creator>Yair Altman</dc:creator> <pubDate>Thu, 25 Feb 2010 20:16:11 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=541#comment-7603</guid> <description>Your first two buttons are zoom and pan, which know of each other and have internal code to handle mutual exclusivity. Your third button is different, so you need to let them know of each other.This is more than the space here allows, so if you want to continue discussion, please contact me offline using the email link on the top-right of this page.</description> <content:encoded><![CDATA[<p>Your first two buttons are zoom and pan, which know of each other and have internal code to handle mutual exclusivity. Your third button is different, so you need to let them know of each other.</p><p>This is more than the space here allows, so if you want to continue discussion, please contact me offline using the email link on the top-right of this page.</p> ]]></content:encoded> </item> <item><title>By: danny</title><link>http://undocumentedmatlab.com/blog/figure-toolbar-components/#comment-7601</link> <dc:creator>danny</dc:creator> <pubDate>Thu, 25 Feb 2010 20:03:28 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=541#comment-7601</guid> <description>OK, I got it to work, but I don&#039;t see any information that corresponds to a &quot;button group&quot;. I was able to copy and paste some code from a GUIDE output file that works as far as creating a &quot;group&quot; of two buttons that are mutually exclusive (a previously selected button will become deselected if the other button becomes selected). However, I&#039;m unable to add my own &quot;custom&quot; button to this group! Any tips? In the example code snippet below, I&#039;m trying to add a third button &quot;select region&quot; to a group of two other buttons. The first two buttons seem to know about each other but don&#039;t see the third button... I think it has something to do with the &quot;createfcn&quot; called &quot;local_CreateFcn&quot; that I copied from the GUIDE output. Any help is MUCH appreciated!!!!!!!!! :-) Thanks!!&lt;pre lang=&quot;matlab&quot;&gt;
icons = load(&#039;icons&#039;) ;
appdata = [];
appdata.lastValidTag = &#039;zoom&#039;;
handles.tb = uitoolbar(...
&#039;Parent&#039;,handles.fig,...
&#039;Tag&#039;,&#039;zoom&#039;,...
&#039;CreateFcn&#039;, {@local_CreateFcn, blanks(0), appdata} );
appdata = [];
appdata.toolid = &#039;Exploration.ZoomIn&#039;;
appdata.CallbackInUse = struct(&#039;ClickedCallback&#039;, &#039;zoom&#039;);
appdata.lastValidTag = &#039;zoom&#039;;
handles.zoom = uitoggletool(...
&#039;Parent&#039;,handles.tb,...
&#039;ClickedCallback&#039;, &#039;zoom&#039;,...
&#039;CData&#039;,icons.zoomin,...
&#039;TooltipString&#039;,&#039;Zoom&#039;,...
&#039;Tag&#039;,&#039;zoom&#039;,...
&#039;CreateFcn&#039;, {@local_CreateFcn, blanks(0), appdata} );
appdata = [];
appdata.toolid = &#039;Exploration.Pan&#039;;
appdata.CallbackInUse = struct(...
&#039;ClickedCallback&#039;, &#039;pan&#039;);
appdata.lastValidTag = &#039;pan&#039;;
handles.pan = uitoggletool(...
&#039;Parent&#039;,handles.tb,...
&#039;ClickedCallback&#039;,&#039;pan&#039;,...
&#039;CData&#039;,icons.pan,...
&#039;TooltipString&#039;,&#039;Pan&#039;,...
&#039;Tag&#039;,&#039;pan&#039;,...
&#039;CreateFcn&#039;, {@local_CreateFcn, blanks(0), appdata} );A = 1 - [ 0 0 0 0 0 0 0 0 0 0 0 ; 0 0 1 1 1 1 1 1 1 0 0 ; 0 0 0 0 0 1 0 0 0 0 0 ; 0 0 0 0 0 1 0 0 0 0 0 ; 0 0 0 0 0 1 0 0 0 0 0 ; 0 0 0 0 0 1 0 0 0 0 0 ; 0 0 0 0 0 1 0 0 0 0 0 ; 0 0 0 0 0 1 0 0 0 0 0 ; 0 0 0 0 0 1 0 0 0 0 0 ; 0 0 0 0 0 1 0 0 0 0 0 ; 0 0 0 0 0 1 0 0 0 0 0 ; 0 0 0 0 0 1 0 0 0 0 0 ; 0 0 0 0 0 1 0 0 0 0 0 ; 0 0 0 0 0 1 0 0 0 0 0 ; 0 0 0 0 0 1 0 0 0 0 0 ; 0 0 0 0 0 1 0 0 0 0 0 ; 0 0 0 0 0 1 0 0 0 0 0 ; 0 0 1 1 1 1 1 1 1 0 0 ;  0 0 0 0 0 0 0 0 0 0 0] + 1 ;
m = gray(2) ;
appdata = [];
appdata.toolid = &#039;Exploration.SelectRegion&#039;;
appdata.CallbackInUse = struct(...
&#039;ClickedCallback&#039;, &#039;&#039;);
appdata.lastValidTag = &#039;selreg&#039;;
handles.selreg = uitoggletool(handles.tb, &#039;TooltipString&#039;, &#039;Select Region&#039;, &#039;OnCallback&#039;, @selreg_on, &#039;OffCallback&#039;, @selreg_off, &#039;CData&#039;, ind2rgb(A, m),...
&#039;CreateFcn&#039;, {@local_CreateFcn, blanks(0), appdata}) ;
endfunction local_CreateFcn(hObject, eventdata, createfcn, appdata)
if ~isempty(appdata)
names = fieldnames(appdata);
for i=1:length(names)
name = char(names(i));
setappdata(hObject, name, getfield(appdata,name));
end
end
if ~isempty(createfcn)
if isa(createfcn,&#039;function_handle&#039;)
createfcn(hObject, eventdata);
else
eval(createfcn);
end
end
end&lt;/pre&gt;</description> <content:encoded><![CDATA[<p>OK, I got it to work, but I don&#8217;t see any information that corresponds to a &#8220;button group&#8221;. I was able to copy and paste some code from a GUIDE output file that works as far as creating a &#8220;group&#8221; of two buttons that are mutually exclusive (a previously selected button will become deselected if the other button becomes selected). However, I&#8217;m unable to add my own &#8220;custom&#8221; button to this group! Any tips? In the example code snippet below, I&#8217;m trying to add a third button &#8220;select region&#8221; to a group of two other buttons. The first two buttons seem to know about each other but don&#8217;t see the third button&#8230; I think it has something to do with the &#8220;createfcn&#8221; called &#8220;local_CreateFcn&#8221; that I copied from the GUIDE output. Any help is MUCH appreciated!!!!!!!!! <img
src='http://undocumentedmatlab.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> Thanks!!</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">    icons = <span style="color: #0000FF;">load</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'icons'</span><span style="color: #080;">&#41;</span> ;    
    appdata = <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>;
    appdata.<span style="">lastValidTag</span> = <span style="color:#A020F0;">'zoom'</span>;
&nbsp;
    handles.<span style="">tb</span> = uitoolbar<span style="color: #080;">&#40;</span><span style="color: #F0F;">...</span>
      <span style="color:#A020F0;">'Parent'</span>,handles.<span style="">fig</span>,<span style="color: #F0F;">...</span>
      <span style="color:#A020F0;">'Tag'</span>,<span style="color:#A020F0;">'zoom'</span>,<span style="color: #F0F;">...</span>
      <span style="color:#A020F0;">'CreateFcn'</span>, <span style="color: #080;">&#123;</span>@local_CreateFcn, blanks<span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>, appdata<span style="color: #080;">&#125;</span> <span style="color: #080;">&#41;</span>;
&nbsp;
    appdata = <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>;
    appdata.<span style="">toolid</span> = <span style="color:#A020F0;">'Exploration.ZoomIn'</span>;
    appdata.<span style="">CallbackInUse</span> = <span style="color: #0000FF;">struct</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'ClickedCallback'</span>, <span style="color:#A020F0;">'zoom'</span><span style="color: #080;">&#41;</span>;
    appdata.<span style="">lastValidTag</span> = <span style="color:#A020F0;">'zoom'</span>;
&nbsp;
    handles.<span style="color: #0000FF;">zoom</span> = uitoggletool<span style="color: #080;">&#40;</span><span style="color: #F0F;">...</span>
      <span style="color:#A020F0;">'Parent'</span>,handles.<span style="">tb</span>,<span style="color: #F0F;">...</span>
      <span style="color:#A020F0;">'ClickedCallback'</span>, <span style="color:#A020F0;">'zoom'</span>,<span style="color: #F0F;">...</span>
      <span style="color:#A020F0;">'CData'</span>,icons.<span style="">zoomin</span>,<span style="color: #F0F;">...</span>
      <span style="color:#A020F0;">'TooltipString'</span>,<span style="color:#A020F0;">'Zoom'</span>,<span style="color: #F0F;">...</span>
      <span style="color:#A020F0;">'Tag'</span>,<span style="color:#A020F0;">'zoom'</span>,<span style="color: #F0F;">...</span>
      <span style="color:#A020F0;">'CreateFcn'</span>, <span style="color: #080;">&#123;</span>@local_CreateFcn, blanks<span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>, appdata<span style="color: #080;">&#125;</span> <span style="color: #080;">&#41;</span>;
&nbsp;
    appdata = <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>;
    appdata.<span style="">toolid</span> = <span style="color:#A020F0;">'Exploration.Pan'</span>;
    appdata.<span style="">CallbackInUse</span> = <span style="color: #0000FF;">struct</span><span style="color: #080;">&#40;</span><span style="color: #F0F;">...</span>
      <span style="color:#A020F0;">'ClickedCallback'</span>, <span style="color:#A020F0;">'pan'</span><span style="color: #080;">&#41;</span>;
    appdata.<span style="">lastValidTag</span> = <span style="color:#A020F0;">'pan'</span>;
&nbsp;
    handles.<span style="">pan</span> = uitoggletool<span style="color: #080;">&#40;</span><span style="color: #F0F;">...</span>
      <span style="color:#A020F0;">'Parent'</span>,handles.<span style="">tb</span>,<span style="color: #F0F;">...</span>
      <span style="color:#A020F0;">'ClickedCallback'</span>,<span style="color:#A020F0;">'pan'</span>,<span style="color: #F0F;">...</span>
      <span style="color:#A020F0;">'CData'</span>,icons.<span style="">pan</span>,<span style="color: #F0F;">...</span>
      <span style="color:#A020F0;">'TooltipString'</span>,<span style="color:#A020F0;">'Pan'</span>,<span style="color: #F0F;">...</span>
      <span style="color:#A020F0;">'Tag'</span>,<span style="color:#A020F0;">'pan'</span>,<span style="color: #F0F;">...</span>
      <span style="color:#A020F0;">'CreateFcn'</span>, <span style="color: #080;">&#123;</span>@local_CreateFcn, blanks<span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>, appdata<span style="color: #080;">&#125;</span> <span style="color: #080;">&#41;</span>;
&nbsp;
    A = <span style="color: #33f;">1</span> - <span style="color: #080;">&#91;</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</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: #33f;">1</span> <span style="color: #33f;">1</span> <span style="color: #33f;">1</span> <span style="color: #33f;">1</span> <span style="color: #33f;">1</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> ; <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">1</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> ; <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">1</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> ; <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">1</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> ; <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">1</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> ; <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">1</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> ; <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">1</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> ; <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">1</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> ; <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">1</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> ; <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">1</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> ; <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">1</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> ; <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">1</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> ; <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">1</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> ; <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">1</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> ; <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">1</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> ; <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">1</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</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: #33f;">1</span> <span style="color: #33f;">1</span> <span style="color: #33f;">1</span> <span style="color: #33f;">1</span> <span style="color: #33f;">1</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> ;  <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span> <span style="color: #33f;">0</span><span style="color: #080;">&#93;</span> + <span style="color: #33f;">1</span> ;
    m = <span style="color: #0000FF;">gray</span><span style="color: #080;">&#40;</span><span style="color: #33f;">2</span><span style="color: #080;">&#41;</span> ;
&nbsp;
    appdata = <span style="color: #080;">&#91;</span><span style="color: #080;">&#93;</span>;
    appdata.<span style="">toolid</span> = <span style="color:#A020F0;">'Exploration.SelectRegion'</span>;
    appdata.<span style="">CallbackInUse</span> = <span style="color: #0000FF;">struct</span><span style="color: #080;">&#40;</span><span style="color: #F0F;">...</span>
      <span style="color:#A020F0;">'ClickedCallback'</span>, <span style="color:#A020F0;">''</span><span style="color: #080;">&#41;</span>;
    appdata.<span style="">lastValidTag</span> = <span style="color:#A020F0;">'selreg'</span>;
    handles.<span style="">selreg</span> = uitoggletool<span style="color: #080;">&#40;</span>handles.<span style="">tb</span>, <span style="color:#A020F0;">'TooltipString'</span>, <span style="color:#A020F0;">'Select Region'</span>, <span style="color:#A020F0;">'OnCallback'</span>, @selreg_on, <span style="color:#A020F0;">'OffCallback'</span>, @selreg_off, <span style="color:#A020F0;">'CData'</span>, ind2rgb<span style="color: #080;">&#40;</span>A, m<span style="color: #080;">&#41;</span>,<span style="color: #F0F;">...</span>
      <span style="color:#A020F0;">'CreateFcn'</span>, <span style="color: #080;">&#123;</span>@local_CreateFcn, blanks<span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>, appdata<span style="color: #080;">&#125;</span><span style="color: #080;">&#41;</span> ;    
  <span style="color: #0000FF;">end</span>
&nbsp;
  <span style="color: #0000FF;">function</span> local_CreateFcn<span style="color: #080;">&#40;</span>hObject, eventdata, createfcn, appdata<span style="color: #080;">&#41;</span>
    <span style="color: #0000FF;">if</span> ~<span style="color: #0000FF;">isempty</span><span style="color: #080;">&#40;</span>appdata<span style="color: #080;">&#41;</span>
      names = <span style="color: #0000FF;">fieldnames</span><span style="color: #080;">&#40;</span>appdata<span style="color: #080;">&#41;</span>;
      <span style="color: #0000FF;">for</span> <span style="color: #0000FF;"><span style="color: #33f;">i</span></span>=<span style="color: #33f;">1</span><span style="color: #F0F;">:</span><span style="color: #0000FF;">length</span><span style="color: #080;">&#40;</span>names<span style="color: #080;">&#41;</span>
        name = <span style="color: #0000FF;">char</span><span style="color: #080;">&#40;</span>names<span style="color: #080;">&#40;</span><span style="color: #0000FF;"><span style="color: #33f;">i</span></span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
        <span style="color: #0000FF;">setappdata</span><span style="color: #080;">&#40;</span>hObject, name, <span style="color: #0000FF;">getfield</span><span style="color: #080;">&#40;</span>appdata,name<span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
      <span style="color: #0000FF;">end</span>
    <span style="color: #0000FF;">end</span>
&nbsp;
    <span style="color: #0000FF;">if</span> ~<span style="color: #0000FF;">isempty</span><span style="color: #080;">&#40;</span>createfcn<span style="color: #080;">&#41;</span>
      <span style="color: #0000FF;">if</span> <span style="color: #0000FF;">isa</span><span style="color: #080;">&#40;</span>createfcn,<span style="color:#A020F0;">'function_handle'</span><span style="color: #080;">&#41;</span>
        createfcn<span style="color: #080;">&#40;</span>hObject, eventdata<span style="color: #080;">&#41;</span>;
      <span style="color: #0000FF;">else</span>
        <span style="color: #0000FF;">eval</span><span style="color: #080;">&#40;</span>createfcn<span style="color: #080;">&#41;</span>;
      <span style="color: #0000FF;">end</span>
    <span style="color: #0000FF;">end</span>
  <span style="color: #0000FF;">end</span></pre></div></div>]]></content:encoded> </item> <item><title>By: Yair Altman</title><link>http://undocumentedmatlab.com/blog/figure-toolbar-components/#comment-7600</link> <dc:creator>Yair Altman</dc:creator> <pubDate>Thu, 25 Feb 2010 19:28:13 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=541#comment-7600</guid> <description>@danny - you need to enable one of the modes before this appdata property becomes available. For example, by clicking on one of the buttons or programmatically (e.g., &lt;i&gt;&lt;b&gt;zoom&lt;/b&gt;(&#039;on&#039;)&lt;/i&gt; or &lt;i&gt;&lt;b&gt;pan&lt;/b&gt;(&#039;on&#039;)&lt;/i&gt;).</description> <content:encoded><![CDATA[<p>@danny &#8211; you need to enable one of the modes before this appdata property becomes available. For example, by clicking on one of the buttons or programmatically (e.g., <i><b>zoom</b>(&#8216;on&#8217;)</i> or <i><b>pan</b>(&#8216;on&#8217;)</i>).</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-09 05:00:04 -->

<!-- W3 Total Cache: Page cache debug info:
Engine:             disk: enhanced
Cache key:          blog/figure-toolbar-components/feed/_index.xml_gzip
Caching:            enabled
Status:             not cached
Creation Time:      0.809s
Header info:
X-Pingback:         http://undocumentedmatlab.com/blog/xmlrpc.php
Set-Cookie:         wpgb_visit_last_php-default=1328788804; expires=Fri, 08-Feb-2013 12:00:04 GMT; path=/
Link:               <http://undocumentedmatlab.com/?p=541>; rel=shortlink
Content-Type:       text/xml; charset=UTF-8
Last-Modified:      Thu, 09 Feb 2012 12:00:04 GMT
Vary:               Accept-Encoding, Cookie
Expires:            Thu, 09 Feb 2012 13:00:04 GMT
Pragma:             public
Cache-Control:      public, must-revalidate, proxy-revalidate
Etag:               21d11d3c119c01e68c69bd73ca1c55b5
Content-Encoding:   gzip
-->
