Ticket #14789 (closed enhancement: fixed)

Opened 8 months ago

Last modified 6 months ago

Add way to disable wxWebView context menu

Reported by: steve_lamerton Owned by:
Priority: low Milestone:
Component: WebView Version: 2.9-svn
Keywords: Cc:
Blocked By: Patch: yes
Blocking:

Description

We can do this using  IDocHostUIHandler::ShowContextMenu for IE, the  context-menu signal for GTK Webkit and  contextMenuItemsForElement in OSX Webkit.

See  wx-dev for more details.

Attachments

context.patch download (2.4 KB) - added by steve_lamerton 8 months ago.
context2.patch download (8.1 KB) - added by steve_lamerton 8 months ago.

Change History

Changed 8 months ago by steve_lamerton

Changed 8 months ago by steve_lamerton

  Changed 8 months ago by steve_lamerton

  • status changed from new to infoneeded_new

I had implemented this on all three platforms now, could someone with a Mac test this for me? It is very simple, just patch, compile, then run the sample. You should be able to get a context menu by right clicking on the page. Try disabling this in the tools menu and then checking that you can't get it to pop up again.

  Changed 8 months ago by evstevemd

  • status changed from infoneeded_new to new

I applied patch and tried it in GTK. I can still see popup menu from sample!

follow-up: ↓ 6   Changed 8 months ago by steve_lamerton

  • status changed from new to infoneeded_new

It works fine for me, did you disable it in the tools menu? What version of WebKitGTK do you have?

  Changed 8 months ago by steve_lamerton

  • patch set

  Changed 8 months ago by vadz

  • status changed from infoneeded_new to new

Sorry, doesn't work for me under OS X (10.8.2) neither: webView:contextMenuItemsForElement:defaultMenuItems: doesn't seem to be called at all.

Also, I had the following when applying the patch:

% g apply-wx context2.patch
context2.patch:9: trailing whitespace.
    virtual void EnableContextMenu(bool enable = true);
context2.patch:22: trailing whitespace.
    DocHostUIHandler(wxWebView* browser) { m_browser = browser; }
context2.patch:24: trailing whitespace.

context2.patch:32: trailing whitespace.

context2.patch:33: trailing whitespace.
private:
 include/wx/gtk/webview_webkit.h |    1 +
 include/wx/msw/webview_ie.h     |    6 +++++-
 include/wx/webview.h            |   13 +++++++++++++
 samples/webview/webview.cpp     |   13 +++++++++++++
 src/gtk/webview_webkit.cpp      |   31 +++++++++++++++++++++++++++++++
 src/msw/webview_ie.cpp          |    7 +++++--
 src/osx/webview_webkit.mm       |    9 +++++++++
 7 files changed, 77 insertions(+), 3 deletions(-)
warning: squelched 72 whitespace errors
warning: 4 lines applied after fixing whitespace errors.

and then when building:

In file included from /Users/zeitlin/src/wx/git/src/common/webview.cpp:22:
/Users/zeitlin/src/wx/git/include/wx/osx/webview_webkit.h:90: warning: unused parameter 'text'
/Users/zeitlin/src/wx/git/include/wx/osx/webview_webkit.h:90: warning: unused parameter 'flags'

in reply to: ↑ 3   Changed 8 months ago by evstevemd

Replying to steve_lamerton:

It works fine for me, did you disable it in the tools menu? What version of WebKitGTK do you have?

There is no that option. Menu is empty.
I use Ubuntu 12.04 with webkit that comes with it, nothing fancy!

  Changed 7 months ago by vadz

I'm pretty sure this means you didn't apply the patch.

  Changed 6 months ago by SJL

  • status changed from new to closed
  • resolution set to fixed

(In [73326]) Add context menu enabling and disabling to wxWebView, all backends supported.

Closes #14789.

  Changed 6 months ago by VZ

(In [73327]) Slight improvements to wxWebView::EnableContextMenu() documentation.

Explain that the menu is enabled by default so the main use of this method is
to disable it.

Also add "@since" tags for the new methods.

And mention this in the changelog.

See #14789.

Note: See TracTickets for help on using tickets.