Opened 18 months ago

Closed 16 months ago

Last modified 16 months ago

#14789 closed enhancement (fixed)

Add way to disable wxWebView context menu

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

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 (2)

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

Download all attachments as: .zip

Change History (11)

Changed 18 months ago by steve_lamerton

Changed 18 months ago by steve_lamerton

comment:1 Changed 18 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.

comment:2 Changed 18 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!

comment:3 follow-up: Changed 18 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?

comment:4 Changed 18 months ago by steve_lamerton

  • Patch set

comment:5 Changed 18 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'

comment:6 in reply to: ↑ 3 Changed 18 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!

comment:7 Changed 18 months ago by vadz

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

comment:8 Changed 16 months ago by SJL

  • Resolution set to fixed
  • Status changed from new to closed

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

Closes #14789.

comment:9 Changed 16 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.