Drop Down Menu Width

6 Ansichten (letzte 30 Tage)
Bruno
Bruno am 21 Apr. 2013
Bearbeitet: Toby am 27 Nov. 2013
The width of the dropdown menus in Matlab GUIs appear to me to be fixed to their designated width. Is there a way to have the width of the drop down portion autosize to display the entire text of all selectable items without impacting the width of the item within the GUI window? See attached image for clarification.
Note: image currently under Mathworks review. Will be uploaded shortly.
  3 Kommentare
Image Analyst
Image Analyst am 21 Apr. 2013
Activate your GUI. Type alt-printscreen to copy it into the clipboard. Go to http://snag.gy and type control-V. Then tell us the URL it gives you.
Bruno
Bruno am 21 Apr. 2013
Bearbeitet: Image Analyst am 22 Apr. 2013

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Walter Roberson
Walter Roberson am 21 Apr. 2013
There is no way to do that, unless it is at the Java level.
What I used to do is calculate the required maximum width, based on the menu contents, and size according to that. That left blank space if the currently chosen menu item was not the widest item, but that is not necessarily a bad thing as users get disconcerted if the controls resize every time you choose a new item. For example, should items (such as other controls) further to the right be shifted left when the user selects a shorter menu item ?
  7 Kommentare
Bruno
Bruno am 22 Apr. 2013
Walter, I created a popup uicontrol item in code and it appears to autosize as you stated it would. Apparently the style of the popups created in GUIDE are "popupmenu" and not "popup". I tried to change the style with set, but it wouldn't allow me which is understandable.
Does anyone know how to change the "popupmenu" created with GUIDE into a "popup"?
Thanks, B
Toby
Toby am 27 Nov. 2013
Bearbeitet: Toby am 27 Nov. 2013
Matlab R2011b doesn't seem to differentiate between uicontrol Style 'popup' and 'popupmenu'. Also, I don't seem to be able to set a preference via the 'setConstrainPopupWidth' method of the underlying com.mathworks.hg.peer.ComboboxPeer$MLComboBox object. It defaults to 'off'; but with any attempt to change it, it remains set as 'off'. Though it looks like an unconstrained width used to be the 'default' feature (see Yair's book - Undocumented Secrets of MATLAB - Java Programming) But just as was the case for Bruno, the width of any dropdown menus in Matlab GUIs appear to me to be fixed to their designated width (as set by the popup uicontrol). Don't know if this is a result of the underlying class changing from a MJComboBox to MLComboBox? Seems like this should be a fairly straight-forward attribute to set though... Anybody know if this is definitely a version issue, or have any further ideas for a work-around?

Melden Sie sich an, um zu kommentieren.


Jan
Jan am 22 Apr. 2013
I have emulated a drop-down menu with a very small button and a UICONTEXTMENU, which is made visible in the button's callback. This works fluently, but the code is much less attractive than a uicontrol('Style', 'popup').

Kategorien

Mehr zu App Building finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by