How to wait for uifigure to resize properly?
18 次查看(过去 30 天)
显示 更早的评论
I am building a rather complex program in appdesigner, which contains axes showing a map. I had difficulties to make sure that the map always stays at the same location whenever I resize the app and whenever I zoom in or out the map shown. I decided to control the resizing behaviour of the uifigure in which I adjust the x,y limits of the uiaxes. I have the following problem:
In the first step the resize function gets the position of a uipanel in which the uiaxes is situated. In the next step this position is used to adjust the position of the uiaxes. It seems that the position is wrong as the resizing of the uipanel is probably not complete. I added the following code to wait for the uifigure resizing and it worked:
uiwait(app.UIFigure,1)
The problem is that I have to wait for 1 second (not possible to set less than 1 second) before the plot is updated.
My questions:
- Why is the resizing function run before all the uifigure components are resized properly?
- How to wait for the resizing? (1 second might not be enough once the uiaxes contains a lot of data)
Effect of uiwait:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/610490/image.png)
2 个评论
Anastasia Eltsova
2021-5-7
Not sure, if it works for you, but I used waitfor() function. It waits for a figure to be complete without async execution
You can read more here Interrupt Callback Execution - MATLAB & Simulink (mathworks.com)
回答(1 个)
Mark
2024-1-19
In my app, I am using AutoResizeChildren, so I cannot use the SizeChangedFcn callback. Instead, I do my resizing within the startupFcn, since it only needs to happen once in my case. However, I was still having issues with the resizing happening before everything had loaded, so the auto resizing did not work as expected. Using drawnow before my positioning changes fixed this issue for me.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Maintain or Transition figure-Based Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!