Mac/UNIX uigetfile dialog box has no title

조회 수: 26 (최근 30일)
Irl Smith
Irl Smith 2017년 4월 21일
댓글: Irl Smith 2019년 8월 17일
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
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)
  댓글 수: 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