WebView加载自定义上下文菜单 [英] webview load custom context menu

查看:148
本文介绍了WebView加载自定义上下文菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在窗口中有一个 WebView 。在 WebView 中,我可以限制它加载其默认上下文菜单。我需要为 WebView 添加一个自定义上下文菜单。因此,请为此发布一个示例。我是Mac开发的新手。请在这个问题上帮助我。

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.

谢谢。

推荐答案

将对象分配为Web视图的 WebUIDelegate 并实现以下委托方法:

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

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

然后可以在上下文菜单中返回所需的菜单项数组。您可以将它们添加到 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.

这篇关于WebView加载自定义上下文菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆