Does anyone know how to put a popup menu in a gui toolbar,
similar to the "Current Directory" popup menu on the
Matlab Desktop? currently I can only find how to add
pushbuttons and toggle buttons to it.
"jason " <mcmains.1@osu.edu> wrote in message
<fjk3ef$sdg$1@fred.mathworks.com>...
> Does anyone know how to put a popup menu in a gui toolbar,
> similar to the "Current Directory" popup menu on the
> Matlab Desktop? currently I can only find how to add
> pushbuttons and toggle buttons to it.
>
> Thanks for any help
> Jason
I don't see in the documentation that this can be done
directly. However, you could do something quick and dirty
like this (watch for wrapping):
"jason " <mcmains.1@osu.edu> wrote in message
<fjk3ef$sdg$1@fred.mathworks.com>...
> Does anyone know how to put a popup menu in a gui toolbar,
> similar to the "Current Directory" popup menu on the
> Matlab Desktop? currently I can only find how to add
> pushbuttons and toggle buttons to it.
>
> Thanks for any help
> Jason
As Matt said, modifying the toolbar is undocumented and
unsupported. You can easily add pushbuttons and
toggle-buttons using the following syntax:
htb = findall(gcf,'tag','FigureToolBar');
if ~isempty(htb)
uitoggletool('tooltip','toggle','seperator','on','parent',htb,'cdata',iconData);
uipushtool(...); % similarly
end
However, trying the same with a uicontrol or javacomponent
is blocked. So, the workaround is to directly add a Java
dropdown
(javax.swing.JComboBox({'here','there','everywhere'})
object) to the underlying Java implementation of the
toolbar. This is slightly more difficult and requires some
Java knowledge. Use my FindJObj submission on the File
Exchange to get started:
jtb = findjobj(gcf,'-nomenu','class','mjtoolbar');
if ~isempty(jtb)
jtb(1).addSeparator;
jcb=javax.swing.JComboBox({'here','there','everywhere'}));
jtb(1).add(jcb);
jtb(1).repaint;
jtb(1).revalidate;
end
Of course, in all events you need to set the action
callback: For pushbuttons/toggle-buttons this is via their
ClickedCallback property; for JComboBox this is via its
ActionPerformedCallback property.
"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message
<fjkema$16s$1@fred.mathworks.com>...
> "jason " <mcmains.1@osu.edu> wrote in message
> <fjk3ef$sdg$1@fred.mathworks.com>...
> > Does anyone know how to put a popup menu in a gui toolbar,
> > similar to the "Current Directory" popup menu on the
> > Matlab Desktop? currently I can only find how to add
> > pushbuttons and toggle buttons to it.
> >
> > Thanks for any help
> > Jason
>
>
> As Matt said, modifying the toolbar is undocumented and
> unsupported. You can easily add pushbuttons and
> toggle-buttons using the following syntax:
>
> htb = findall(gcf,'tag','FigureToolBar');
> if ~isempty(htb)
>
>
uitoggletool('tooltip','toggle','seperator','on','parent',htb,'cdata',iconData);
> uipushtool(...); % similarly
> end
>
> However, trying the same with a uicontrol or javacomponent
> is blocked. So, the workaround is to directly add a Java
> dropdown
> (javax.swing.JComboBox({'here','there','everywhere'})
> object) to the underlying Java implementation of the
> toolbar. This is slightly more difficult and requires some
> Java knowledge. Use my FindJObj submission on the File
> Exchange to get started:
>
> jtb = findjobj(gcf,'-nomenu','class','mjtoolbar');
> if ~isempty(jtb)
> jtb(1).addSeparator;
> jcb=javax.swing.JComboBox({'here','there','everywhere'}));
> jtb(1).add(jcb);
> jtb(1).repaint;
> jtb(1).revalidate;
> end
>
> Of course, in all events you need to set the action
> callback: For pushbuttons/toggle-buttons this is via their
> ClickedCallback property; for JComboBox this is via its
> ActionPerformedCallback property.
>
> Yair Altman
> http://ymasoftware.com
I just found out that you don't need to use findjobj to find
the underlying Java toolbar jtb:
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.