[英]mouseDown event on NSSlider
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.我有一个 NSslider,我用它来控制 QTMovie 的慢跑速度。
I want the rate of the video to playback according to the slider value.我希望根据 slider 值播放视频的速率。 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.问题是当用户的事件“mouseUp”完成时,我希望 NSSlider 重置为“0”。 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.
我似乎无法让这个事件起作用,所以我将 NSSlider 子类化并实现了 mousedown 和 mouseup 方法,并将一个委托添加到 NSSlider 子类并将其连接到我的应用程序的 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.它有点工作,但在 slider 上有很大的延迟 - 它滑动得很好,但视频速率没有改变,只有当我“mouseUp”时才会改变 - 基本上看起来 mouseDown 是在 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:我的 NSSlider subclass.m 文件:
@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];
}
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):在我称为 TimeScrubberSlider 的 NSSlider 的子类中,以下代码似乎是我需要的(希望有人会发现这很有用):
#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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.