2011-02-26 8 views
0

전체 화면 모드로 설정하는 NSWindow가 있습니다. 마우스를 사용하지 않을 때 숨길 수 있기를 원합니다 (마지막 사용 후 15 초). 다음과 같이 내 응용 프로그램 대리자를 가지고 :매 x 초마다 메서드를 호출하려면 어떻게해야합니까?

MyMediaRoomAppDelegate.h :

#import <Cocoa/Cocoa.h> 

@interface MyMediaRoomAppDelegate : NSResponder <NSApplicationDelegate> { 
    NSWindow *window; 
    NSDate *lastMouseMove; 
} 

@property (assign) IBOutlet NSWindow *window; 
@property (nonatomic, retain) NSDate *lastMouseMove; 

@end 

MyMediaRoomAppDelegate.m : 나는 후 커서를 다시 숨기는 방법입니다 확실하지 않다 무엇

#import "MyMediaRoomAppDelegate.h" 

@implementation MyMediaRoomAppDelegate 

@synthesize window; 
@synthesize lastMouseMove; 

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { 
    // The application has just finished lanching 

    // Grab the screen size 
    NSRect screenRect; 
    screenRect = [[NSScreen mainScreen] frame]; 

    // Setup the window - full screen 
    [[self window] setLevel:NSMainMenuWindowLevel+1]; 
    [[self window] setStyleMask:NSBorderlessWindowMask]; 
    [[self window] setOpaque:YES]; 
    [[self window] setBackgroundColor:[NSColor blackColor]]; 
    [[self window] setFrame:screenRect display:YES animate:NO]; 

    // Setup the mouse 
    [[self window] setAcceptsMouseMovedEvents:YES]; 
    [[self window] makeFirstResponder:self]; 
    [NSCursor hide]; 
} 

- (BOOL)acceptsFirstResponder 
{ 
    return YES; 
} 

- (void)mouseMoved:(NSEvent *)theEvent 
{ 
    [NSCursor unhide]; 
    [self setLastMouseMove: [NSDate date]]; 
} 

@end 

15 초. 것은 15 초가 지나면 [NSCursor hide]을 호출하지 않고 setLastMouseMove, 매초마다 확인해야합니다.

답변

1

시도 NSTimer. 생성시 반복되도록 지정할 수 있습니다.

관련 문제