Can't deactivate slider

7 Ansichten (letzte 30 Tage)
Andrew Diamond
Andrew Diamond am 19 Aug. 2018
Kommentiert: Image Analyst am 21 Aug. 2018
I have a callback (not the slider) in which until it's complete I don't want the user using the slider. So, in that callback I disabled the slider (i.e.'enable', 'off'). The property editor shows that to be the case. However, if I click on the slider the enable property turns back on. I can bypass the logic in the slider callback (that's a different callback) but even so the slider indicator (the thing that moves on the slider to show you where you are) still moves.
So, is there anyway to stop/disable user input from triggering the slider to begin with?

Antworten (2)

Image Analyst
Image Analyst am 19 Aug. 2018
Well you can hide it. Try setting the visible property to off
handles.slider1.Visible = 'off';
  2 Kommentare
Image Analyst
Image Analyst am 19 Aug. 2018
Andrew's "Answer" moved here since it's not an answer to his original question, but actually a reply to me:
First, is that any different than
set(handles.slider1, 'visible', 'off')?
I don't want it to "disappear" which is what I think that would do (right?). That would make the GUI look kludgy I think. What I'm looking for is something that prevents it from getting user input (i.e. mouse clicks) but not affect its look or ability to be manipulated programmatically. Long story short, I want to move the sliders indicator programmatically in the aforementioned call back routine (the non-slider one that I tried deactivating the slider in)
Thx
Image Analyst
Image Analyst am 19 Aug. 2018
Andrew, you're using the old fashioned way. I'm using the modern OOP way. They're equivalent.
See my other answer for a fully functioning demo.

Melden Sie sich an, um zu kommentieren.


Image Analyst
Image Analyst am 19 Aug. 2018
Andrew, try the attached demo. It works as expected.
  2 Kommentare
Andrew Diamond
Andrew Diamond am 21 Aug. 2018
Thanks so much.
Not quite sure whether the right thing to do is accept this as an answer because what it seems to be is that to have the slider indicator show up/move via programmatic control (that you can see via the indicator) of the slider but not mouse control requires the slider's enable state to "inactive" vs off.
Note, the reason my slider seemed to "re-animate" (after setting it to "off") from just clicking on the slider (after I set enable to of)f was because I had forgotten in this mass of old code that I had installed a mousebutton down on the slider for some reason which actually turned enable back on! Duh. If it wasn't for your example that confirmed that just clicking on the slider didn't, as a default, didn't do that it probably would have taken a lot longer to find that issue.
Image Analyst
Image Analyst am 21 Aug. 2018
I do not change the slider value by programmatic control (code). I do let you change it by clicking on it with the mouse (mouse control). Then the push buttons enable or disable the slider plus the text above the slider.
I'm glad it helped you figure out that the problem lied with some other function. You could at least vote for the solution if you don't consider that it helped enough to be an answer.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by