Getting GUI Slider updates while dragging
8 ビュー (過去 30 日間)
古いコメントを表示
Is there a straightforward method to get updates on a slider's position while it is being dragged? The standard callback gets called only after the drag is complete and the button has been released.
I'm thinking of using the ButtonDownFcn to start a polling loop checking the slider's value. (Then how do I detect mouse up?)
3 件のコメント
採用された回答
Sean de Wolski
2012 年 10 月 23 日
This can be done easily with addlistener
h = uicontrol('style','slider','callback',@(src,evt)disp(get(src,'value')));
addlistener(h,'Value','PreSet',@(~,~)disp('hi'));
3 件のコメント
Stephen23
2016 年 1 月 24 日
Mohamad Roslan Mohd Roshdi also created a question here: http://www.mathworks.com/matlabcentral/answers/264979-continuous-slider-callback-how-to-get-value-from-addlistener
その他の回答 (1 件)
AG
2019 年 2 月 20 日
The following worked for me. I get a 'live' scroll-bar update by calling this within another function:
slider_value = get(gcf.Children(j), 'Value');
...where j is the value of the UIcontrol corresponding to the scroll. You can find out which UIControl it is in the figure by putting a break in the code and using:
gcf.Children
This could also be ascertained in run-time using:
for j = 1:length(gcf.Children)
get(gcf.Children(j), 'Tag')
end
which will return a char array with the Tag of each of the children which could then be compared using strcmp(), for example. I've done this using a GUI created with GUIDE.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Migrate GUIDE Apps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!