Can we specify or make uigetfile() remember its window position or view mode/sorting?

50 views (last 30 days)
I've always avoided using uigetfile() because of how cumbersome it is and because it doesn't adhere to any of my system preferences that affect file management dialogs in other applications. It never remembers what the last path was or how the window was configured.
I've managed to implement a workaround for making the path persistent, but I'm struggling to figure out any acceptable way of managing the window size, view mode, and sorting behavior without manually mousing every single time.
I could probably resort to doing some sort of bash script with xdotool and wmctrl that waits for the dialog to appear, but I want to know if there's something at least a little less ridiculous, but less involved than reimplementing the whole thing. I'm open to undocumented solutions, as I'm probably going to be the only one using it. Web searches haven't turned up anything, but I figured I'd ask.
  2 Comments
Walter Roberson
Walter Roberson on 17 Nov 2025 at 21:19
There might possibly have been some mechanism in R2019b (which you noted as your release), but by R2025a there is no hope.
DGM
DGM on 17 Nov 2025 at 22:02
I didn't even want to open that can of worms, because that's pretty much where I expected things were going.

Sign in to comment.

Answers (2)

Matt J
Matt J on 17 Nov 2025 at 23:14
Edited: Matt J on 18 Nov 2025 at 0:22
This file exchange submission seems to do most of the above,
The last position of the dialog is remembered automatically, and the FilterSpec option can beused ot specify the initial folder path.
  6 Comments
Matt J
Matt J on 18 Nov 2025 at 3:59
Edited: Matt J on 18 Nov 2025 at 4:03
That doesn't stop me from programmatically building a UI, but it's probably less convenient than intended.
Since you have R2019b, you still have GUIDE. I wonder if the text field issue affects that as well. If not, that would give you a better GUI-building alternative than purely programmatic GUI construction.

Sign in to comment.


DGM
DGM on 19 Nov 2025 at 5:02
Edited: DGM on 23 Nov 2025 at 6:49
I just made an embarrassing bash kludge as a workaround. It works good enough for now, but I'm not going to post that mess on the forum. Reimplementing the dialog would be the proper way, but I don't need it that badly, and I can't expect that it'll work for anyone else in newer versions, so the total value is limited.
As a side note, I did notice that in fact uigetfile() did once have the ability to specify the window location. By R2019b, it was mentioned in the synopsis, but had been internally disabled -- or rather, it says it will be "ignored", but it's only safely ignored for certain cases. Otherwise it causes an error instead.
EDIT:
In my testing of my own lazy idea, I discovered several annoyances that limit the practicality of any solution which uses uigetfile() at all.
  • I'd prefer to have a tabular view sorted descending by date (so that new items are on top). While I can sort by date, the view only realistically supports ascending sorting by any field. Otherwise, the file/directory precedence is also reversed.
  • While the tabular view works on the initial directory displayed in the dialog, navigating to any other directory will change the table width to some arbitrary narrow width which is smaller than even that associated with the default window size. Consequently, one can never actually make use of a larger window.
  • The dialog always shows hidden files, and I know of no way to control that. Maybe it could be done by complicating the filter expression, but I haven't figured it out.
So long story short, I can't fix these things with window management or input automation tools. If I want a roughly normal file dialog that has a working tabular view, I'd have to reimplement it. A lot of the underlying tools are in private m-code. That might be of use, though I don't know that I'd bother reimplementing everything (e.g. stuff like default file selection).
As an aside, I don't know why the small-icon view is always so common, unless it's just one of those things that's just "always been that way". I would have expected the waning ubiquity of 8.3 filenames would have made this zig-zag reading task into a universal frustration, but maybe everyone loves doing eyeball gymnastics.

Categories

Find more on Environment and Settings in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!