2014-09-27 37 views
0

我搜索如何創建單擊後顯示光標位置的應用程序。我發現如何報告當前的鼠標位置,但我不知道如何顯示在我的窗口中!單擊後顯示鼠標位置(objective-c)

我想簡單地點擊一個位置,並顯示該位置的窗口標籤

上的Xcode的文檔,我覺得- (void)mouseUp:(NSEvent *)theEvent但我不知道怎麼用這個!

回答

1

Subclass your NSWindow and then override the mouseDown Event Method

- (void)mouseDown:(NSEvent *)theEvent 
{ 
    //get the point position where the mouse was clicked on the NSWindow ! 
    NSPoint event_location = [theEvent locationInWindow]; 
    NSLog(@"Clicked %f %f",event_location.x,event_location.y); 
    // use event_location.x and event.location.y to show the position whereever you like 
} 
相關問題