Update NSSlider value in real time
In my swift app 3, I have an NSSlider that I created like this:
self.myAwesomeSlider = NSSlider(frame:CGRect(x: 10, y: 100, width: 20, height: 300))
self.myAwesomeSlider?.cell = NSSlider()
self.myAwesomeSlider?.maxValue = 127
self.myAwesomeSlider?.target = self
self.myAwesomeSlider?.isContinuous = true
self.view?.addSubview(self.myAwesomeSlider!)
What I want to do now is (from another function) update the value of this slider in real time.
I tried to make it very simple:
self.myAwesomeSlider?.integerValue = Int(value)
but it doesn't update point. I want to get a new value that is calculated and the point on the slider moves according to the value.
Is it possible?
Thank you
Edit
self.myAwesomeSlider?.integerValue = Int(value)
It seems to work, however I have to click on another app before I see the actual change.
+3
source to share