The standard callback of the slider is called, when the mouse is released:
function main
sld = uicontrol('Style', 'slider', 'Callback', {@callbk, 'released'});
sld.addlistener('ContinuousValueChange', @(h, e) callbk(h, e, 'moved'));
end
function callbk(SliderH, EventData, Event)
disp(Event)
end
The WindowButtonDownFcn does not trigger, when the mouse is over the slider.
Then Java helps:
function main
hSlider = uicontrol('style','slider');
jScrollBar = findjobj(hSlider);
jScrollBar.AdjustmentValueChangedCallback = @(h,e) callbk(h, e, 'moved');
jScrollBar.MousePressedCallback = @(h,e) callbk(h, e, 'clicked');
jScrollBar.MouseReleasedCallback = @(h,e) callbk(h, e, 'released');
end
function callbk(SliderH, EventData, Event)
disp(Event)
end
Best Answer