继续跟踪鼠标拖动事件,即使光标移出电影之后 [英] continue tracking mouse-drag event even after cursor moves out of the movie

查看:296
本文介绍了继续跟踪鼠标拖动事件,即使光标移出电影之后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很少的视图在父视图中的网格中对齐(所有都是NSView的)



我覆盖
- (void)mouseDown:(NSEvent *)事件
- (void)mouseDragged:(NSEvent *)子视图子类中某些自定义绘图的事件



具体来说,



问题:当光标移出子视图时(在鼠标拖动期间),显然我不能跟踪事件,因此我不能调整矩形的大小。
我想跟踪鼠标移动甚至在应用程序窗口外...(现在只是拖动事件)



有没有明显或复杂的方法实现此.....



感谢提前



Rajesh


< (NSEvent *)theEvent
{
NSPoint point;


while(1){
theEvent = [[self window] nextEventMatchingMask:(NSLeftMouseDraggedMask | NSLeftMouseUpMask)];
point = [self convertPoint:[theEvent locationInWindow] fromView:nil];

//执行点

if([TheEvent type] == NSLeftMouseUp)
break;
}
}


I have few views aligned in grids in parent view (All being NSView's )

I am overriding -(void)mouseDown:(NSEvent *)event - (void)mouseDragged:(NSEvent *)theEvent for some custom drawing in child view subclass

To be specific, I draw some rectangle boxes during mouse drag in child view's.

Problem: when cursor moves out of the child view( during mouse drag ) , obviously, I am not able to track the event and hence I cannot resize the rectangle. I want to track the mouse movements even outside the application window... (for now just the drag event )

Is there any obvious or complex way to achieve this.....

Thanks in Advance

Rajesh

解决方案

- (void)mouseDown:(NSEvent *)theEvent
{
    NSPoint point;
    while (1) {
        theEvent = [[self window] nextEventMatchingMask: (NSLeftMouseDraggedMask | NSLeftMouseUpMask)];
        point = [self convertPoint: [theEvent locationInWindow] fromView: nil];

        // do something with point

        if ([theEvent type] == NSLeftMouseUp)
            break;
    }
}

这篇关于继续跟踪鼠标拖动事件,即使光标移出电影之后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆