<?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="https://undocumentedmatlab.com/articles/figure-toolbar-components/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/figure-toolbar-components?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=figure-toolbar-components</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Sun, 07 Nov 2021 10:33:24 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.3</generator>
	<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/figure-toolbar-components#comment-512145</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Sun, 07 Nov 2021 10:33:24 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=541#comment-512145</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/figure-toolbar-components#comment-511739&quot;&gt;Santiago&lt;/a&gt;.

@Santiago - AFAIK you cannot parent a Matlab uimenu or uitoolbar to a uitab. However, you can add Java components (in your case, &lt;a href=&quot;https://docs.oracle.com/javase/8/docs/api/javax/swing/JMenuBar.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;JMenuBar&lt;/code&gt;&lt;/a&gt; and &lt;a href=&quot;https://docs.oracle.com/javase/8/docs/api/javax/swing/JToolBar.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;JToolBar&lt;/code&gt;&lt;/a&gt;) using the &lt;a href=&quot;http://undocumentedmatlab.com/articles/javacomponent&quot;&gt;&lt;b&gt;&lt;i&gt;javacomponent&lt;/i&gt;&lt;/b&gt;&lt;/a&gt; function.

However, IMHO a better alternative would be to set the uitabgroup&#039;s &lt;b&gt;SelectionChangedFcn&lt;/b&gt; property to a custom Matlab callback function, that would hide/show various components in the top-level (figure) menu-bar and toolbar based on the currently-selected tab.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/figure-toolbar-components#comment-511739">Santiago</a>.</p>
<p>@Santiago &#8211; AFAIK you cannot parent a Matlab uimenu or uitoolbar to a uitab. However, you can add Java components (in your case, <a href="https://docs.oracle.com/javase/8/docs/api/javax/swing/JMenuBar.html" target="_blank" rel="nofollow"><code>JMenuBar</code></a> and <a href="https://docs.oracle.com/javase/8/docs/api/javax/swing/JToolBar.html" target="_blank" rel="nofollow"><code>JToolBar</code></a>) using the <a href="http://undocumentedmatlab.com/articles/javacomponent"><b><i>javacomponent</i></b></a> function.</p>
<p>However, IMHO a better alternative would be to set the uitabgroup&#8217;s <b>SelectionChangedFcn</b> property to a custom Matlab callback function, that would hide/show various components in the top-level (figure) menu-bar and toolbar based on the currently-selected tab.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Santiago		</title>
		<link>https://undocumentedmatlab.com/articles/figure-toolbar-components#comment-511739</link>

		<dc:creator><![CDATA[Santiago]]></dc:creator>
		<pubDate>Thu, 30 Sep 2021 19:12:15 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=541#comment-511739</guid>

					<description><![CDATA[Hi Yair, excellent blog as always. 
I have the doubt if it is possible to use an uitab as a parent of an uimenu or a toolbar?
I&#039;d like to add one of those options to my uitab. 
Thanks.]]></description>
			<content:encoded><![CDATA[<p>Hi Yair, excellent blog as always.<br />
I have the doubt if it is possible to use an uitab as a parent of an uimenu or a toolbar?<br />
I&#8217;d like to add one of those options to my uitab.<br />
Thanks.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/figure-toolbar-components#comment-391192</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Fri, 21 Oct 2016 08:58:26 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=541#comment-391192</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/figure-toolbar-components#comment-391191&quot;&gt;Sebastian&lt;/a&gt;.

@Sebastian - I agree that this is confusing. I am not aware of a way to avoid this.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/figure-toolbar-components#comment-391191">Sebastian</a>.</p>
<p>@Sebastian &#8211; I agree that this is confusing. I am not aware of a way to avoid this.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Sebastian		</title>
		<link>https://undocumentedmatlab.com/articles/figure-toolbar-components#comment-391191</link>

		<dc:creator><![CDATA[Sebastian]]></dc:creator>
		<pubDate>Fri, 21 Oct 2016 08:53:56 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=541#comment-391191</guid>

					<description><![CDATA[I&#039;m not sure if this is a common problem. But some of our clients (including me as well) are confused about the behavior of the figure toolbars when docked. In later releases (~R2012 and above) these toolbars are automatically moved to the Matlab ToolStrip when docked into the main window. This makes access to the toolbar harder and much slower, especially if the docking position is at the bottom of the main window.

Is there a way to avoid this behavior, so that the toolbar stays on its figure window when docked?]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not sure if this is a common problem. But some of our clients (including me as well) are confused about the behavior of the figure toolbars when docked. In later releases (~R2012 and above) these toolbars are automatically moved to the Matlab ToolStrip when docked into the main window. This makes access to the toolbar harder and much slower, especially if the docking position is at the bottom of the main window.</p>
<p>Is there a way to avoid this behavior, so that the toolbar stays on its figure window when docked?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Kesh		</title>
		<link>https://undocumentedmatlab.com/articles/figure-toolbar-components#comment-329948</link>

		<dc:creator><![CDATA[Kesh]]></dc:creator>
		<pubDate>Wed, 20 Aug 2014 21:36:41 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=541#comment-329948</guid>

					<description><![CDATA[I&#039;m implementing a Matlab application with &quot;dynamic&quot; tabs (adding/deleting tabs with their own menu &#038; toolbar items on the fly.) So, it just happened to be a major issue for me, unfortunately. I&#039;ll look into ComponentHierarchyChanged although I&#039;ve tried several other events/callbacksyet, but so far no success. It would&#039;ve been nice if ObjectBeingDeleted event is present for Java objects...]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m implementing a Matlab application with &#8220;dynamic&#8221; tabs (adding/deleting tabs with their own menu &amp; toolbar items on the fly.) So, it just happened to be a major issue for me, unfortunately. I&#8217;ll look into ComponentHierarchyChanged although I&#8217;ve tried several other events/callbacksyet, but so far no success. It would&#8217;ve been nice if ObjectBeingDeleted event is present for Java objects&#8230;</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/figure-toolbar-components#comment-329943</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Wed, 20 Aug 2014 20:35:18 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=541#comment-329943</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/figure-toolbar-components#comment-329942&quot;&gt;Kesh&lt;/a&gt;.

@Kesh - You could possibly trap the ComponentHierarchyChanged callback (or something similar) and then re-update the toolbar.

But I really don&#039;t see this as a major issue: people rarely reorder toolbar components, and when they do it&#039;s mostly when the GUI is first created, so it&#039;s easy to simply update the java stuff after that point, instead of before as you have done.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/figure-toolbar-components#comment-329942">Kesh</a>.</p>
<p>@Kesh &#8211; You could possibly trap the ComponentHierarchyChanged callback (or something similar) and then re-update the toolbar.</p>
<p>But I really don&#8217;t see this as a major issue: people rarely reorder toolbar components, and when they do it&#8217;s mostly when the GUI is first created, so it&#8217;s easy to simply update the java stuff after that point, instead of before as you have done.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Kesh		</title>
		<link>https://undocumentedmatlab.com/articles/figure-toolbar-components#comment-329942</link>

		<dc:creator><![CDATA[Kesh]]></dc:creator>
		<pubDate>Wed, 20 Aug 2014 20:24:25 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=541#comment-329942</guid>

					<description><![CDATA[Hey Yair,

I just bumped into an aggravating issue with Java toolbar components (R2014a) which I don&#039;t think has been brought up on this site.

The problem: Java based toolbar components disappear when their ancestral figure&#039;s Children property is permuted (including running uistack function). It appears that when figure&#039;s Children is permuted, it invalidates jToolbar object (i.e., ComponentPeer of uitoolbar&#039;s JavaContainer). Here is a minimum working example:

&lt;pre lang=&quot;matlab&quot;&gt;
fig = figure(&#039;MenuBar&#039;,&#039;none&#039;);

% create a couple menu items
h1 = uimenu(&#039;parent&#039;,fig,&#039;label&#039;,&#039;&#038;File&#039;);
h2 = uimenu(&#039;parent&#039;,fig,&#039;label&#039;,&#039;&#038;Edit&#039;);

% add a toolbar
tb = uitoolbar(&#039;Parent&#039;,fig);

% add a black uipushtool button
uipushtool(&#039;Parent&#039;,tb,&#039;CData&#039;,zeros(16,16,3,&#039;uint8&#039;));
drawnow

% add a JButton on the toolbar
jToolbar = get(get(tb,&#039;JavaContainer&#039;),&#039;ComponentPeer&#039;);
jtbRun = javax.swing.JButton(&#039;JButton&#039;);
jToolbar.add(jtbRun); %1st position
jToolbar.repaint;
jToolbar.revalidate;

drawnow

fprintf(&#039;jToolbar is valid: %d\n&#039;,jToolbar.isValid())
fprintf(&#039;jtbRun is valid: %d\n&#039;,jtbRun.isValid())

h = get(fig,&#039;Children&#039;);
set(fig,&#039;Children&#039;,h([1 3 2]))
drawnow

fprintf(&#039;jToolbar is valid: %d\n&#039;,jToolbar.isValid())
fprintf(&#039;jtbRun is valid: %d\n&#039;,jtbRun.isValid())
&lt;/pre&gt;

Do you have any (elegant) workaround for this problem?]]></description>
			<content:encoded><![CDATA[<p>Hey Yair,</p>
<p>I just bumped into an aggravating issue with Java toolbar components (R2014a) which I don&#8217;t think has been brought up on this site.</p>
<p>The problem: Java based toolbar components disappear when their ancestral figure&#8217;s Children property is permuted (including running uistack function). It appears that when figure&#8217;s Children is permuted, it invalidates jToolbar object (i.e., ComponentPeer of uitoolbar&#8217;s JavaContainer). Here is a minimum working example:</p>
<pre lang="matlab">
fig = figure('MenuBar','none');

% create a couple menu items
h1 = uimenu('parent',fig,'label','&amp;File');
h2 = uimenu('parent',fig,'label','&amp;Edit');

% add a toolbar
tb = uitoolbar('Parent',fig);

% add a black uipushtool button
uipushtool('Parent',tb,'CData',zeros(16,16,3,'uint8'));
drawnow

% add a JButton on the toolbar
jToolbar = get(get(tb,'JavaContainer'),'ComponentPeer');
jtbRun = javax.swing.JButton('JButton');
jToolbar.add(jtbRun); %1st position
jToolbar.repaint;
jToolbar.revalidate;

drawnow

fprintf('jToolbar is valid: %d\n',jToolbar.isValid())
fprintf('jtbRun is valid: %d\n',jtbRun.isValid())

h = get(fig,'Children');
set(fig,'Children',h([1 3 2]))
drawnow

fprintf('jToolbar is valid: %d\n',jToolbar.isValid())
fprintf('jtbRun is valid: %d\n',jtbRun.isValid())
</pre>
<p>Do you have any (elegant) workaround for this problem?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/figure-toolbar-components#comment-311666</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Sun, 26 Jan 2014 17:03:31 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=541#comment-311666</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/figure-toolbar-components#comment-311660&quot;&gt;Michele&lt;/a&gt;.

@Michele - you&#039;re probably forgetting that all callbacks automatically recieve the event object handle (a double in the case of HG1) as a first parameter, and eventData as the second parameter.

The correct way to define such a callback is:
&lt;pre lang=&#039;matlab&#039;&gt;set(hButton, &#039;ClickedCallback&#039;, @(hButton,e) obj.myMethod(hButton));&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/figure-toolbar-components#comment-311660">Michele</a>.</p>
<p>@Michele &#8211; you&#8217;re probably forgetting that all callbacks automatically recieve the event object handle (a double in the case of HG1) as a first parameter, and eventData as the second parameter.</p>
<p>The correct way to define such a callback is:</p>
<pre lang='matlab'>set(hButton, 'ClickedCallback', @(hButton,e) obj.myMethod(hButton));</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Michele		</title>
		<link>https://undocumentedmatlab.com/articles/figure-toolbar-components#comment-311660</link>

		<dc:creator><![CDATA[Michele]]></dc:creator>
		<pubDate>Sun, 26 Jan 2014 16:19:13 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=541#comment-311660</guid>

					<description><![CDATA[Hi 

i&#039;m trying to run a class method trough a uipushbutton clickedcallback call.
The issue is that I get the error

&lt;pre&gt;
Undefined function &quot;mymethod&quot; for input arguments of type &#039;double&#039;.
Error while evaluating uipushtool ClickedCallback
&lt;/pre&gt;
I can just run normal function but this is not useful for me
]]></description>
			<content:encoded><![CDATA[<p>Hi </p>
<p>i&#8217;m trying to run a class method trough a uipushbutton clickedcallback call.<br />
The issue is that I get the error</p>
<pre>
Undefined function "mymethod" for input arguments of type 'double'.
Error while evaluating uipushtool ClickedCallback
</pre>
<p>I can just run normal function but this is not useful for me</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/figure-toolbar-components#comment-295528</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Fri, 15 Nov 2013 01:30:45 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=541#comment-295528</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/figure-toolbar-components#comment-274057&quot;&gt;Daniel&lt;/a&gt;.

@Daniel - I think the easiest solution in your case would be to use the standard Matlab figure toolbar, and simply hide those buttons that you don&#039;t need by setting their &lt;b&gt;Visible&lt;/b&gt; property to &#039;off&#039;.

Related: http://undocumentedmatlab.com/blog/customizing-standard-figure-toolbar-menubar/]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/figure-toolbar-components#comment-274057">Daniel</a>.</p>
<p>@Daniel &#8211; I think the easiest solution in your case would be to use the standard Matlab figure toolbar, and simply hide those buttons that you don&#8217;t need by setting their <b>Visible</b> property to &#8216;off&#8217;.</p>
<p>Related: <a href="http://undocumentedmatlab.com/blog/customizing-standard-figure-toolbar-menubar/" rel="ugc">http://undocumentedmatlab.com/blog/customizing-standard-figure-toolbar-menubar/</a></p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
