This can only be done by subclassification (methods, for example, from @mprudhom, will not work 100% to release information)
To start dragging you need to catch becomeFirstResponder (for this you also need to provide needsPanelToBecomeKey )
to complete the drag you need to subclass mouseDown: (it is called mouseDown, but it is called when the handle is released)
Note: this approach will make your slider the first responder, canceling any other current responder
Note: approach from mprudhom
@implementation CustomSlider - (void)mouseDown:(NSEvent *)theEvent { [super mouseDown:theEvent]; NSLog(@"OK"); } - (BOOL)needsPanelToBecomeKey { [super needsPanelToBecomeKey]; return YES; } - (BOOL)becomeFirstResponder { [super becomeFirstResponder]; NSLog(@"Became first responder."); return YES; } @end
Peter Lapisu
source share