Even though the callback of the slider isn't being called as the mouse is moved, the 'Value'
property of the slider uicontrol is being updated. Therefore, you could create a listener using addlistener
that will execute a given callback when the 'Value'
property changes. Here's an example:
hSlider = uicontrol('Style', 'slider', 'Callback', @(s, e) disp('hello'));
hListener = addlistener(hSlider, 'Value', 'PostSet', @(s, e) disp('hi'));
As you move the slider you should see 'hi'
being printed to the screen (the listener callback), and when you release the mouse you will see 'hello'
printed (the uicontrol callback).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…