Sonu
Sonu

Reputation: 105

webview load custom context menu

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.

Upvotes: 4

Views: 2080

Answers (1)

Rob Keniger
Rob Keniger

Reputation: 46028

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.

Upvotes: 6

Related Questions