0

I have hit a bit of a wall and would really appreciate some help.

I have an NSSlider that I am using to control the jog speed of a QTMovie.

I want the rate of the video to playback according to the slider value. This is easy to do.

The problem is that I want the NSSlider to reset to '0' when the user's event "mouseUp" is completed. I can't seem to get this event to work, so I have subclassed NSSlider and implemented mousedown & mouseup methods, and added a delegate to the NSSlider subclass and connected that to my app's controller.

It sort of works, but there is a massive delay on the slider - it slides fine, but the video rate doesn't change, and only does when I 'mouseUp' - basically it seems the mouseDown is called on the MouseUp.

I hope some of that makes sense.

Hopefully someone out there can help me out,

Cheers,

Adam

enter code here

my NSSlider subclass .m file:

@implementation TimeScrubberSlider
 
@synthesize delegate;
 
 
- (void)mouseDown:(NSEvent *)theEvent  {
 
// dispatch_queue_t myQueue = dispatch_queue_create("com.mycompany.myqueue", 0);
// dispatch_async(myQueue, ^{
 
  NSLog(@"mouseDown");
  [super mouseDown:theEvent];
  if ([delegate respondsToSelector: @selector(doScrubTime:)])
  {
  [delegate doScrubTime:nil];
  }
  [super mouseDown:theEvent];
 
// );
// dispatch_release(myQueue);
 
}
 
 
- (void) mouseUp: (NSEvent*) theEvent
{
  NSLog(@"mouseUp TimeScrubber");
  [super mouseUp:theEvent];
  [self setDoubleValue:0];
  if ([delegate respondsToSelector: @selector(doScrubTime:)])
  {
  [delegate doScrubTime:nil];
  }
  [super mouseUp:theEvent];
 
}
 
adamteale
  • 940
  • 2
  • 12
  • 27

1 Answers1

2

I think I have it working now.

In the subclass of NSSlider that I have called TimeScrubberSlider, the following code seems to what I need (hopefully someone will find this useful):

#import "TimeScrubberSlider.h"
#import "Controller.h"

@implementation TimeScrubberSlider

@synthesize delegate;


- (void)mouseDown:(NSEvent *)theEvent  {

    [delegate doScrubTime:nil];
    [super mouseDown:theEvent];
    [self mouseUp:theEvent];

}


- (void) mouseUp: (NSEvent*) theEvent
{

    [self setIntValue:0];
    [delegate doPlay:nil];

}

@end
sjngm
  • 12,423
  • 14
  • 84
  • 114
adamteale
  • 940
  • 2
  • 12
  • 27