NSSlider 上的 mouseDown 事件
我遇到了一些困难,非常感谢一些帮助。
我有一个 NSSlider,用来控制 QTMovie 的点动速度。
我希望根据滑块值播放视频的速率。这很容易做到。
问题是我希望当用户的事件“mouseUp”完成时 NSSlider 重置为“0”。 我似乎无法让这个事件起作用,所以我对 NSSlider 进行了子类化并实现了 mousedown 和 mousedown 。 mouseup 方法,并向 NSSlider 子类添加委托并将其连接到我的应用程序的控制器。
它有点工作,但滑块上有很大的延迟 - 它滑动得很好,但视频速率没有改变,并且只有当我“mouseUp”时才会改变 - 基本上看起来 mouseDown 是在 MouseUp 上调用的。
我希望其中一些是有道理的。
希望有人可以帮助我,
干杯,
Adam
enter code here
我的 NSSlider 子类 .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 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];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我现在已经可以使用了。
在我称为 TimeScrubberSlider 的 NSSlider 子类中,以下代码似乎是我所需要的(希望有人会发现这很有用):
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):