Mac/UNIX uigetfile dialog box has no title

19 次查看(过去 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?

采纳的回答

Connor Flynn
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 个评论
Irl Smith
Irl Smith 2019-8-17
After some poking around with UNIX command "find", I found the following file:
/Applications/MATLAB_R2018b.app/toolbox/matlab/uitools/uigetfile.m
That file contains essentially only the following line:
[filename, pathname, filterindex] = uigetputfile_helper(0, varargin{:});
I haven't gone looking for the latter file (uigetputfile_helper.m). Am I on the track you propose?
Walter Roberson
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
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)
  2 个评论
Irl Smith
Irl Smith 2017-4-24
Thanks! I was looking for such a note and missed it. I'll make a point of looking for Note: next time I notice such a thing.
Irl Smith
Irl Smith 2019-8-17
I unaccepted the answer because Connor Flynn provided a workaround. Your answer does answer my original question, but I like workarounds if available. I hope you're not offended at the unaccept!

请先登录,再进行评论。


Hardy Hall
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 个评论
Daniel Bertrand
Daniel Bertrand 2018-9-24
So far Matlab just ignore the Mac problems...
Walter Roberson
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
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
  1 个评论
Irl Smith
Irl Smith 2019-8-17
I'll try it out. I'm temporarily not on that project but I'll take some time to implement your suggestions. Thanks for the tip, and thanks also for reminding me about "which". (I can never remember what "which", "what", "who", etc., do. Not to mention "whois" ;-) .)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by