setIgnoresMouseEvents:YES 不起作用(例如闪烁窗口)
我认为我的问题最好在视频中描述: http://cl.ly/5Iou
基本上,我'我在我的窗口中创建一个跟踪区域,如下所示:
NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:[self frame] options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways owner:self userInfo:nil];
[self addTrackingArea:area];
[area release];
然后我实现了:
-(void)mouseEntered:(NSEvent *)event {
[self toggleDetail];
}
-(void)mouseExited:(NSEvent *)event {
[self toggleDetail];
}
在 awakeFromNib
中我放置了这个:
[attachedWindow setIgnoresMouseEvents:YES];
toggleDetail
看起来有点类似于:(弹出窗口是一个MAAttachedWindow
)
- (void)toggleDetail {
if (!attachedWindow) {
NSPoint buttonPoint = NSMakePoint(NSMidX([conditionImage frame]),
NSMidY([conditionImage frame]));
attachedWindow = [[MAAttachedWindow alloc] initWithView:view
attachedToPoint:buttonPoint
inWindow:[self window]
onSide:12
atDistance:65.0];
//irrelevant window setup here
[[self window] addChildWindow:attachedWindow ordered:NSWindowAbove];
}
else {
[[self window] removeChildWindow:attachedWindow];
[attachedWindow orderOut:self];
[attachedWindow release];
attachedWindow = nil;
}
}
因此,正如您在视频中看到的,如果我将鼠标移到窗口上远离窗口,然后将其移到弹出窗口上,则不会发生“脉冲”。但是,如果我将鼠标移到弹出窗口将出现的大致区域,然后将鼠标移到窗口中,它就会发出脉冲。看起来窗口几乎没有时间注册它不应该接收鼠标事件。有什么想法吗?我已经无计可施,试图解决这个问题。
I think my problem can best be described in a video: http://cl.ly/5Iou
Basically, I'm creating a tracking area in my window like this:
NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:[self frame] options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways owner:self userInfo:nil];
[self addTrackingArea:area];
[area release];
Then I've implemented:
-(void)mouseEntered:(NSEvent *)event {
[self toggleDetail];
}
-(void)mouseExited:(NSEvent *)event {
[self toggleDetail];
}
And in awakeFromNib
I put this:
[attachedWindow setIgnoresMouseEvents:YES];
toggleDetail
looks somewhat similar to this: (the popup is a MAAttachedWindow
)
- (void)toggleDetail {
if (!attachedWindow) {
NSPoint buttonPoint = NSMakePoint(NSMidX([conditionImage frame]),
NSMidY([conditionImage frame]));
attachedWindow = [[MAAttachedWindow alloc] initWithView:view
attachedToPoint:buttonPoint
inWindow:[self window]
onSide:12
atDistance:65.0];
//irrelevant window setup here
[[self window] addChildWindow:attachedWindow ordered:NSWindowAbove];
}
else {
[[self window] removeChildWindow:attachedWindow];
[attachedWindow orderOut:self];
[attachedWindow release];
attachedWindow = nil;
}
}
So, as you can see in the video, the "pulsing" doesn't happen if I move my mouse over the window away from the window, then move it over the popup window. However, if I move my mouse over the general vicinity where the popup window will appear, then move my mouse into the window, it pulses. It almost seems like the window doesn't have time to register that it shouldn't receive mouse events. Any ideas? I've reached my wits ends trying to work around this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哇,那很简单。我刚刚想通了。我正在调用这个:
在窗口初始化之前。因此,由于某种原因,它没有注册。所以,我把它移到了这里:
所以,就在它初始化之后,但就在它显示之前。终于可以工作了! :)
Wow, that was simple. I just figured it out. I was calling this:
before the window had initialized. Thus it didn't register for some reason. So, I moved it here:
So, right after it's initialized, but right before it's displayed. Finally it's working! :)