Patrik Dendis
Patrik Dendis

Reputation: 313

Right click on OSX new item

I would like to advice from you. It is possible to add new item to right click on OSX? For example I select any word in safari, TextEdit, Notes, Pages, Preview and I would like send this word to the server and get response. It is possible? Can you give me any hint how should I start?

Upvotes: 2

Views: 226

Answers (1)

JaredH
JaredH

Reputation: 2398

You could try something like:

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

}

Read more here.

Upvotes: 2

Related Questions