2016-01-12 75 views
2

我想徵詢您的意見。可以添加新項目,在OSX上點擊右鍵?例如,我選擇safari,TextEdit,Notes,Pages,Preview中的任何單詞,並且我希望將這個單詞發送到服務器並獲得響應。有可能的?你能否給我任何提示,我應該如何開始?右鍵單擊OSX新項目

+0

https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/SysServices/introduction.html – pvg

+0

哦和https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG /專門分享擴展 – pvg

+0

你有更好的例子嗎?謝謝 –

回答

2

你可以嘗試這樣的:

- (void)mouseDown:(NSEvent *)theEvent { 

    NSMenu *theMenu = [[NSMenu alloc] initWithTitle:@"Contextual Menu"]; 

    [theMenu insertItemWithTitle:@"Beep" action:@selector(beep:) keyEquivalent:@"" atIndex:0]; 

    [theMenu insertItemWithTitle:@"Honk" action:@selector(honk:) keyEquivalent:@"" atIndex:1]; 

    [NSMenu popUpContextMenu:theMenu withEvent:theEvent forView:self]; 

} 

更多here