Mac/UNIX uigetfile dialog box has no title
15 次查看(过去 30 天)
显示 更早的评论
On Windows,
uigetfile(FilterSpec,DialogTitle)
displays a dialog box with the specified title. On a Mac, the title doesn't appear. Is there a way to get the title of the dialog to appear?
0 个评论
采纳的回答
Connor Flynn
2019-8-17
The work-around I've used is to couple calls to uigetfile with a test of "ispc". If ~ispc, then issue the command "menu(dialog,'OK');" which will generate a menu displaying the desired dialog string which the MacOSX user is forced to aknowledge before the un-titled uigetfile interface comes up. At least then they know what they are supposed to be selecting. For example: if "title_str" contains the title you want displayed...
if ~ispc; menu(title_str,'OK'); end
[fname,pname] = uigetfile('*.*',title_str);
For PC users, they only see the uigetfile dialog box with desired title. For MacOSX users, they initially see a menu with a title from title_str. After selecting "OK", then they see an untitled uigetfile dialog box, but by then they know what to select.
3 个评论
Walter Roberson
2019-8-17
>> which -all uigetputfile_helper
/Applications/MATLAB_R2019a.app/toolbox/matlab/uitools/private/uigetputfile_helper.m % Private to uitools
更多回答(3 个)
Megha Parthasarathy
2017-4-24
Hello,
This is an OS (El Capitan) design and not a MATLAB software bug that causes the title bar to not be displayed in the dialog box. The visual characteristics of the dialog box depend on the operating system that runs your code. For instance, some operating systems do not show title bars on dialog boxes. If you pass a dialog box title to the uigetfile function, those operating systems will not display the title. (Refer to the note at the end of the description in the documentation for uigetfile: uigetfile)
Hardy Hall
2018-2-2
Can someone suggest a simple workaround since the problem is persisting in 2018 with OS X 10.13.3 Thanks
2 个评论
Walter Roberson
2018-9-24
MATLAB invokes native operating system routines for file selection in order to support the native os look and feel.
There are Java based file selection boxes that you could invoke if having the title is more important for your purposes.
Connor Flynn
2019-8-17
Yes, but I do have to provide the caveat that I have not tested this on any flavor of linux other than Mac OSX.
Rather than use the UNIX "find" command, it might be preferable to use which('uigetfile') from within Matlab itself to make sure you are editing the instance of uigetfile that is top-most in the path. (The "which" command will default to giving you the top-most instance even if multiple instances are found.)
You don't need to dig into uigetpufile_helper. Just before it is called insert the test of whether it is a PC or not. That is, insert the line:
if ~ispc && nargin>=2 ; menu(varargin{2},'OK'); end
just before the call to uigetputfile_helper.
I am typically reluctant to edit Mathworks-supplied functions in place. Instead, if/when I do edit Mathworks-supplied functions, I will save my edited copy in my local user space at "userpath". But I found when doing this with uigetfile.m, it generated an unexpected function-no-found error for "warnfiguredialog" on line 127. I defeated this by making sure 'warnfiguredialog' is a known function by replacing the original line 127
if ~(matlab.internal.environment.context.isWebAppServer)
with:
if ~(matlab.internal.environment.context.isWebAppServer)&&~isempty(whos('warnfiguredialog'))
.
This seems to work from my end, but I am on a PC and my colleague with Mac OSX has gone home for the day. Let me know if this works for you.
Cheers,
Connor
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!