webview load custom context menu

本秂侑毒 提交于 2019-12-10 17:29:59

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/6585075/webview-load-custom-context-menu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!