CefView / QCefView

A Qt Widget encapsulated CEF view based on QWidget
https://cefview.github.io/QCefView/
GNU Lesser General Public License v2.1
529 stars 137 forks source link

[BUG]: linux下右键菜单功能如何实现? #119

Closed tonyzhou1985 closed 2 years ago

tonyzhou1985 commented 2 years ago

Describe the bug 【Bug描述】

1.0.3版本在linux下只有osr模式,在osr模式下,右键菜单不能显示。

To Reproduce 【复现步骤】

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior 【正确的预期行为】

希望能正常显示右键菜单功能

Screenshots 【截图】

...

Environment 【BUG产生的环境】

Additional context 【更多额外信息】

...

tishion commented 2 years ago

OSR模式下,右键菜单需要自己通过QT绘制,或者通过web前端页面绘制。

tonyzhou1985 commented 2 years ago

用qt自己绘制是可以实现自定义的菜单,如果要实现原有的那些右键菜单,比如输入框右键【复制】【粘帖】【全选】等功能如何实现?另外qt实现的菜单显示位置如何定位?

tishion commented 2 years ago

CefFrame有一些方法,不过目前没有通过QCefView暴露出来。 https://magpcss.org/ceforum/apidocs3/projects/(default)/CefFrame.html

  // Execute undo in this frame.
  ///
  /*--cef()--*/
  virtual void Undo() = 0;

  ///
  // Execute redo in this frame.
  ///
  /*--cef()--*/
  virtual void Redo() = 0;

  ///
  // Execute cut in this frame.
  ///
  /*--cef()--*/
  virtual void Cut() = 0;

  ///
  // Execute copy in this frame.
  ///
  /*--cef()--*/
  virtual void Copy() = 0;

  ///
  // Execute paste in this frame.
  ///
  /*--cef()--*/
  virtual void Paste() = 0;

  ///
  // Execute delete in this frame.
  ///
  /*--cef(capi_name=del)--*/
  virtual void Delete() = 0;

  ///
  // Execute select all in this frame.
  ///
  /*--cef()--*/
  virtual void SelectAll() = 0;

后面再增加方法暴露这几个方法的功能。

tonyzhou1985 commented 2 years ago

非常感谢大佬解答。

tishion commented 2 years ago

https://github.com/CefView/QCefView/pull/124 OSR增加了右键菜单的处理,右键菜单的行为现在受到setContextMenuPolicy函数的控制。 如果当前QCefView设置了Qt::DefaultContextMenuPolicy,则显示CEF默认的native 右键菜单,其他任何值,都不会显示默认菜单,可以考虑使用Qt绘制,或者JavaScript绘制。

tonyzhou1985 commented 2 years ago

这两天我也自己用qt实现了下。不过没你这个好用。非常感谢大佬。

------------------ 原始邮件 ------------------ 发件人: "Sheen @.>; 发送时间: 2022年7月1日(星期五) 下午4:52 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [CefView/QCefView] [BUG]: linux下右键菜单功能如何实现? (Issue #119)

124

OSR增加了右键菜单的处理,右键菜单的行为现在受到setContextMenuPolicy函数的控制。 如果当前QCefView设置了Qt::DefaultContextMenuPolicy,则显示CEF默认的native 右键菜单,其他任何值,都不会显示默认菜单,可以考虑使用Qt绘制,或者JavaScript绘制。

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>