Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 通过自动选择上下文菜单选项自动关闭自定义创建的窗口_Objective C_Macos_Cocoa_Xcode7_Nsmenu - Fatal编程技术网

Objective c 通过自动选择上下文菜单选项自动关闭自定义创建的窗口

Objective c 通过自动选择上下文菜单选项自动关闭自定义创建的窗口,objective-c,macos,cocoa,xcode7,nsmenu,Objective C,Macos,Cocoa,Xcode7,Nsmenu,我已经建立了一个自定义窗口;在这个窗口中,我显示的是按钮。 如果单击按钮,我将显示上下文菜单。 问题是我不想关闭我的窗口,但不知何故,当我从nsmenu中选择选项时,鼠标退出事件就会被触发 我想防止这种影响。 我想不出来 任何帮助都将不胜感激。 提前谢谢 -(void)rightMouseDown:(NSEvent *)theEvent { NSMenu *theMenu = [[NSMenu alloc] initWithTitle:@"Contextual Menu"];

我已经建立了一个自定义窗口;在这个窗口中,我显示的是按钮。 如果单击按钮,我将显示上下文菜单。 问题是我不想关闭我的窗口,但不知何故,当我从nsmenu中选择选项时,鼠标退出事件就会被触发

我想防止这种影响。 我想不出来

任何帮助都将不胜感激。 提前谢谢

-(void)rightMouseDown:(NSEvent *)theEvent
{
     NSMenu *theMenu = [[NSMenu alloc] initWithTitle:@"Contextual Menu"];

            [[theMenu addItemWithTitle:@"Remove From List" action:@selector(removeWithIdentifier) keyEquivalent:@""] setTarget:self];
            [[theMenu addItemWithTitle:@"Open" action:@selector(openAppWithIdentifier) keyEquivalent:@""] setTarget:self];

            [theMenu popUpMenuPositioningItem:nil atLocation:NSMakePoint(self.bounds.size.width-20, self.bounds.size.height-10) inView:self];
}

-(void)removeWithIdentifier
{
     //My custom view is getting mouse exited event from here
     //I want prevent it.
}

嘿,朋友们,我已经得到了答案

我发现,如果您的窗口级别为“NSPOUPMENUWindowLevel”,则 视图已在其上实现任何上下文菜单,则此视图将始终获取鼠标退出事件

张贴供日后参考

谢谢