Mac/UNIX uigetfile dialog box has no title

17 vues (au cours des 30 derniers jours)
Irl Smith
Irl Smith le 21 Avr 2017
Commenté : Irl Smith le 17 Août 2019
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?

Réponse acceptée

Connor Flynn
Connor Flynn le 17 Août 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 commentaires
Irl Smith
Irl Smith le 17 Août 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 le 17 Août 2019
>> which -all uigetputfile_helper
/Applications/MATLAB_R2019a.app/toolbox/matlab/uitools/private/uigetputfile_helper.m % Private to uitools

Connectez-vous pour commenter.

Plus de réponses (3)

Megha Parthasarathy
Megha Parthasarathy le 24 Avr 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 commentaires
Irl Smith
Irl Smith le 24 Avr 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 le 17 Août 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!

Connectez-vous pour commenter.


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

Connectez-vous pour commenter.


Connor Flynn
Connor Flynn le 17 Août 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 commentaire
Irl Smith
Irl Smith le 17 Août 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" ;-) .)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Environment and Settings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by