Continuously pressing GUI slider arrow causes hanging
Show older comments
based on the following question: https://es.mathworks.com/matlabcentral/answers/49905-continuously-pressing-gui-slider-arrow-causes-hanging
The solution proposed doen't woks for me.
I've created a GUI with a slider control that update a graph. When I make distinct individual clicks of the slider arrows, it works fine, even if it takes some seconds to update the figure. When I hold the arrow buttons down continuously the figure is updated to the final value of the slider, however, matlab is still busy processing the long function repeatedly.
What appears to be happening is that by holding down the arrow, the slider callback and the corresponding slow function gets launched many times repeatedly. The BusyAction and the interrupting callback don't apply to the slow function that has already been lunched. Ultimately, it is accoumulated in the queue and keep the program busy.
Is there some way that the continuous-arrow-press condition is suppressed? Or might there be some way to force the GUI to wait until all other graphics and uicontrol data in the figure are refreshed before re-executing the callback?
Here there is part of the code to better understand the problem
S.Slider = uicontrol('style','slider', 'callback', @Slider_A); %generate the slider
function Slider_A(My_Slider, ~, ~)
S = guidata(My_Slider); % Get S struct from the figure
S.Value = get(My_Slider, 'Value');
% w = waitforbuttonpress; %this would work if exist waitforbuttonRELEASE
update(S); %slow function and plotting
guidata(My_Slider, S); % Store modified S in figure
end
Accepted Answer
More Answers (0)
Categories
Find more on Creating, Deleting, and Querying Graphics Objects 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!