EZFrag
EZFrag

Reputation: 302

Objective C : Show contextual menu on left click

I have a contextual menu on a NSImageView which is displayed when the user right clicks on the NSImageView. I would also like it to be displayed when a user left clicks. The menu is created using the IB and is linked up to the NSImageView via the IB.

I thought about "calling" the right click event, but I couldn't find any useful information about that.

Upvotes: 1

Views: 506

Answers (1)

Ken Thomases
Ken Thomases

Reputation: 90531

You can call the following, where view is your image view:

NSPoint location = [view convertPoint:event.locationInWindow fromView:nil];
[view.menu popUpMenuPositioningItem:nil atLocation:location inView:view];

Upvotes: 1

Related Questions