如何将上下文菜单附加到 TChromium 浏览器
我有一个来自 Delphi Chromium Embedded 的 TChromium broser (http://code.google.com/p/delphichromiumembedded)。我想为其附加一个上下文菜单。我怎样才能做到这一点?
I have a TChromium broser from Delphi Chromium Embedded (http://code.google.com/p/delphichromiumembedded). I would like to attach a context menu to it. How I can achieve that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要处理
OnBeforeMenu
事件。在该事件处理程序中,将输出参数Result
设置为True
即可,这将禁止弹出默认上下文菜单。之后,您可以在从menuInfo
结构。下面是带有自定义弹出菜单的代码示例:
更新:
对于动态创建的实例,您必须手动分配事件处理程序。尝试以下代码。
You need to handle the
OnBeforeMenu
event. In that event handler is enough to set the output parameterResult
toTrue
what will suppress the default context menus to popup. After that you can display your own menu on the positions obtained from themenuInfo
structure.Here's the code sample with a custom popup menu:
Update:
For dynamically created instance you have to assign the event handler manually. Try the following code.
实际上,如果您已经可以构建 chromium 的上下文菜单,则不需要 popupmenu 并且不必将 vcl.menus 单元添加到您的应用程序中。而且 chromium 自己的菜单比使用老式 win32 api 库的 vcl 更现代、更清晰,并且绘制性能更快。
cef3 的菜单完全可以像这样配置。
note:SetAccelerator shortcuts only functional if popup appears.so you may need onPreKeyEvent
actually you dont need popupmenu and you dont have to have add vcl.menus unit into your application if you have already can build chromium's context menu. also chromium's own menu is more modern and clear look like and faster draw perfrmance rather than a vcl which uses vintage win32 api library.
cef3 has its menu totally configurable like this.
note:SetAccelerator shortcuts only functional if popup appears.so you may need onPreKeyEvent