I have some NSSliders hooked up on my UI to text fields with formatters, all 
set up with bindings so that the label shows the slider value. The sliders are 
continuous, looks fine, nice feedback for whoever’s driving. 

However I want to capture, in the app, the value of the slider only at the end 
when the mouse goes up, once. That value ends up being sent out over bluetooth, 
and I really don’t want to send 100 float values a second, when only the last 
one matters anyway. Probably just trying would cause bad things to happen. 

I’m used to UIKit which has the alternate form of action handling method which 
gives you the event, but AppKit doesn’t have that unfortunately. 

I can’t capture mouseDown and mouseUp because the control gets them

I tried a NSEvent.addLocalMonitorForEventsMatchingMask() but that doesn’t 
capture events inside tracking loops, so I get the mouse down, and that’s it, 
the slider eats the rest, which doesn’t help. 

In the action handing code, which gets called all the time, I can call 
NSEvent.pressedMouseButtons() and that does appear to work and let me find the 
final value. I didn’t get great comfort from the documentation that this is 
reliable however. 

I can subclass NSSlider or possibly NSSliderCell but that sounds like a whole 
world of pain, if I have to do that I’ll probably just put a coalescing delay 
into the whole thing which waits 1/2 second after an update before it actually 
does the update. 

Any good ways to do this? 
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to