4

I have a WebView in a window. In the WebView, I am able to restrict it to load its default contextual menu. I need to add a custom contextual menu for the WebView. So, please post a sample regarding this. I am new to Mac development. Please help me in this issue.

Thanks in advance.

Rob Keniger
  • 45,830
  • 6
  • 101
  • 134
Sonu
  • 105
  • 7

1 Answers1

6

Assign an object as the web view's WebUIDelegate and implement this delegate method:

- (NSArray *)webView:(WebView *)sender contextMenuItemsForElement:(NSDictionary *)element defaultMenuItems:(NSArray *)defaultMenuItems

You can then return an array of menu items that you want in the contextual menu. You can either add them to the defaultMenuItems array or return a new array containing only your items.

Rob Keniger
  • 45,830
  • 6
  • 101
  • 134