How to wait for uifigure to resize properly?
18 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Anastasia Eltsova
el 7 de Mayo de 2021
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)
Respuestas (1)
Mark
el 19 de En. de 2024
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 comentarios
Ver también
Categorías
Más información sobre Maintain or Transition figure-Based Apps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!