Determine when NSSlider knob is 'let go' in continuous mode

后端 未结 7 1088
青春惊慌失措
青春惊慌失措 2020-12-17 10:19

I\'m using an NSSlider control, and I\'ve configured it to use continuous mode so that I can continually update an NSTextField with the current value of the slider while the

相关标签:
7条回答
  • 2020-12-17 10:45

    Unfortunately the two needs are contradictory due to the way basic Cocoa controls are designed. If you're using the target/action mechanism, you're still firing the action in continuous or non-continuous mode. If you're using Bindings, you're still triggering KVO.

    One "quick" solution to this might be to subclass NSSlider/NSSliderCell and override the mouse dragging machinery to call super then post a custom "NSSliderDidChangeTemporaryValue" (or whatever name you choose) notification with self as the object. Leave it set to NOT be continuous so the change is only "committed for realz" when the user's done dragging but you can still observe the "user-proposed value" notification and update your UI however you wish.

    No need to watch for mouse up or implement complicated "don't-change-yet-im-still-draggin" logic that way.

    0 讨论(0)
提交回复
热议问题