Position of Not-visible figure is WRONG (two monitors bug?)
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Veronica Taurino am 10 Mai 2022
Kommentiert: dpb am 12 Mai 2022
If I create a figure and maximize it, I got sizes fitting my second monitor:
fig = figure('Menu','none','ToolBar','none','WindowState','maximized','Visible','on');
0.0010 0.0490 1.2800 0.6493
But if I create a not visibile figure, I got a wrong position:
fig = figure('Menu','none','ToolBar','none','WindowState','maximized','Visible','off');
360 198 560 420
Moreover, if I change the visible property to "ON", Matlab at first shows me the same wrong position (even if the figure is indeed maximized, I can see it on the screen):
but when I click on "show all properties", it shows the right position:
0.0010 0.0490 1.2800 0.6493
How can I solve this? I need it to properly define some sizes in my App (app designer).
For now, I create a figure, store the position and close it. But I would like the user didn't see an empty figure during the process.
dpb am 11 Mai 2022
Again, you can avoid that by a selective workaround of a set of coordinates that you know are going to be in the visible range...depends upon which effect you think the lesser evil -- the temporary figure flicker or not being exactly where you want it.
I'd think it possible to figure out an algorithm about where your position is that you could compute a satisfactory set of coordinates from the data that are available.
dpb am 10 Mai 2022
I deal with it by having a usersettings structure saved as a .mat file that contains all the stuff to restore from the user's last session including the last position of figures where the user left them. The startup function reloads all those so the figure will be recreated where the user last left it. If the file doesn't exist, then there are some system defaults that are reasonable for the number/size of monitor(s).
You can discover the number and size of monitors at the time your app starts by querying the root properties of the graphics environment. See the doc section titled "Root Properties" under Graphics Object Properties
With that data, you can set reasonable bounds based on the user's environment and not be dependent upon the defaults as your present method is.
dpb am 12 Mai 2022
Yeah, Walter, I didn't even begin to touch that level of detail -- in my environment at least, it's good enough to have the figure be on the screen; ime the user will always end up tweaking/moving stuff around anyways, no matter how finely-tuned the developer thinks they've made it.
Sometimes, there is no practical alternative but "perfect enough"...
Weitere Antworten (0)
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!