游戏全屏时如何阻挡热门角落? 当在系统中启用热角并且游戏全屏时,当我将光标移动到任何角落游戏时最小化。
我像这样改为全屏:
fullscreenWindow = [[NSWindowFullscreen alloc] initWithContentRect:frame styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer: NO];
mainWindow = [self window];
[mainWindow setAcceptsMouseMovedEvents:NO];
[mainWindow orderOut:nil];
// Set the options for our new fullscreen window
[fullscreenWindow setReleasedWhenClosed: YES];
[fullscreenWindow setLevel: NSFloatingWindowLevel];
[fullscreenWindow setHidesOnDeactivate:YES];
[fullscreenWindow setContentView: self];
[fullscreenWindow makeKeyAndOrderFront:self];
[fullscreenWindow makeFirstResponder:self];
[fullscreenWindow setAcceptsMouseMovedEvents:YES];
答案 0 :(得分:2)
当鼠标位于顶部时,您可以更改鼠标位置。
- (void)mouseMoved:(NSEvent *)theEvent
{
NSPoint mouseLoc;
mouseLoc = [NSEvent mouseLocation]; //get current mouse position
//mouse position change
CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState);
int Height = (int)ScrnRect.size.height;
// NSLog(@"Height::%d,MouSe.Y::%f",Height,mouseLoc.y);
if(Height < mouseLoc.y+5 ){
CGEventRef mouse = CGEventCreateMouseEvent (NULL, kCGEventMouseMoved, CGPointMake( mouseLoc.x, 5), 0);
CGEventPost(kCGHIDEventTap, mouse);
CFRelease(mouse);
CFRelease(source);
}
}
答案 1 :(得分:0)
在 setLevel:中尝试更高级别 您不仅限于NSWindow Class Reference中的那些。 这些只是#define为Quartz / Core Graphics中的子集所做的其他名称。 在常量中查看它们 https://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/Quartz_Services_Ref/Reference/reference.html