> On Dec 29, 2015, at 12:44 AM, Roland King <r...@rols.org> wrote:
> 
> 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, 


Actually it's easy. For very similar reasons I needed the same behavior - live 
update of the slider's temp value for UI elements, but only call the final 
setter when the user is done. I subclassed NSSlider's keyUp: and keyDown: to 
call super and then call my own delegate method "sliderDidEndUpdate:"


_______________________________________________

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