Create a custom control. Here is what I do for my custom controls:
Interface first:
@interface AS_CustomControl : NSControl <NSCoding> { } @end
Then implementation:
@implementation AS_CustomControl -(id)initWithFrame:(NSRect)rect { if (self = [super initWithFrame:rect]) { [self initCustomControl]; } return self; } -(id)initWithCoder:(NSCoder*)coder { if (self = [super initWithCoder:coder]) { [self initCustomControl]; } return self; } -(void)initCustomControl {
The cellClass method ensures that your user control will trigger action messages when the user interacts with it.
Now this should be the case of drawing the waveform in drawRect: and redefining the messages mouseDown: mouseDragged: and mouseUp: to handle the range selection.
source share