Slow SizeChangedFcn or ResizeFcn
49 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jan
el 26 de Jul. de 2020
Comentada: Clinten Graham
el 26 de Jun. de 2023
When a SizeChangedFcn or ResizeFcn takes some time, the figure size can be changed, until the display is updated. Example:
function ResizeTest
FigH = figure('Units', 'Pixels');
siz = get(FigH, 'Position');
AxesH = axes('Units', 'Pixels', 'Position', [5, 5, siz(3:4)-10], 'Box', 'on');
set(FigH, 'ResizeFcn', {@resize, AxesH}); % Same for SizeChangedFcn
end
function resize(FigH, EventData, AxesH)
siz = get(FigH, 'Position');
pause(1.0); % Of course here are some real calculations
set(AxesH, 'Position', [5, 5, siz(3:4)-10]);
end
The real calculations are e.g. a re-wrapping of a large text displayed in the axes object.
During the mouse is moved to change the figure, the display is smartly changed, but when the axes object is adjusted, its size is likely out of date.
What is a good strategy to solve this problem? It would be best to trigger the callback, when the mouse button is released. But in Matlab 6.5 to 2018b (most likely newer versions also) the motion of the mouse calls the callback already. Setting the figure property Interruptible to 'on' and the BusyAction to 'queue' does not solve the problem - this is the default already.
1 comentario
Respuesta aceptada
Jan
el 4 de Ag. de 2020
2 comentarios
Jiri Hajek
el 10 de Jun. de 2021
Hi Jan,
I do have a related problem with a SizeChangedFcn, for which I have no solution so far. I need to make an adjustment to the position of certain objects in app gui after all auto resizing is done. While debugging, the adjustments work fine, but when I run the app without interruption, the adjustments are done before all automatic resizing is finished, which effectively makes them useless... Would you care you share your ideas about solving such a situation?
Ver también
Categorías
Más información sobre Loops and Conditional Statements 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!