Mac/UNIX uigetfile dialog box has no title

17 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Connor Flynn
Connor Flynn il 17 Ago 2019
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 Commenti
Irl Smith
Irl Smith il 17 Ago 2019
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 il 17 Ago 2019
>> which -all uigetputfile_helper
/Applications/MATLAB_R2019a.app/toolbox/matlab/uitools/private/uigetputfile_helper.m % Private to uitools

Accedi per commentare.

Più risposte (3)

Megha Parthasarathy
Megha Parthasarathy il 24 Apr 2017
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 Commenti
Irl Smith
Irl Smith il 24 Apr 2017
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 il 17 Ago 2019
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!

Accedi per commentare.


Hardy Hall
Hardy Hall il 2 Feb 2018
Can someone suggest a simple workaround since the problem is persisting in 2018 with OS X 10.13.3 Thanks
  2 Commenti
Daniel Bertrand
Daniel Bertrand il 24 Set 2018
So far Matlab just ignore the Mac problems...
Walter Roberson
Walter Roberson il 24 Set 2018
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.

Accedi per commentare.


Connor Flynn
Connor Flynn il 17 Ago 2019
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 Commento
Irl Smith
Irl Smith il 17 Ago 2019
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" ;-) .)

Accedi per commentare.

Categorie

Scopri di più su Environment and Settings in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by