Drop Down Menu Width
8 次查看(过去 30 天)
显示 更早的评论
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 个评论
Image Analyst
2013-4-21
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.
回答(2 个)
Walter Roberson
2013-4-21
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 个评论
Toby
2013-11-27
编辑:Toby
2013-11-27
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?
Jan
2013-4-22
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').
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!