【问题标题】:Fullscreen how to block hot corners全屏如何遮挡热点
【发布时间】:2012-07-09 20:09:53
【问题描述】:

游戏全屏时如何遮挡热点? 当系统中启用热角并且游戏处于全屏状态时,当我将光标移动到任何角落时,游戏会最小化。

我像这样切换到全屏:

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];

【问题讨论】:

    标签: objective-c xcode cocoa fullscreen quartz-2d


    【解决方案1】:

    当鼠标位置在顶部时您可以更改的鼠标位置。

    - (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);
            }
        }
    

    【讨论】:

      【解决方案2】:

      setLevel: 中尝试更高级别 您不限于 NSWindow 类参考中的那些。 这些只是#define 为 Quartz/Core Graphics 中的一部分命名的其他名称。 在常量中查看它们 https://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/Quartz_Services_Ref/Reference/reference.html

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-04-20
        • 2022-01-24
        • 2011-06-27
        • 2014-09-22
        • 2013-03-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多