Contextmenu: Additional entries

Having problems with building or using the JCEF Java binding? Ask your questions here.

Contextmenu: Additional entries

Postby edominic » Thu Aug 13, 2015 1:36 am

Hey guys,
little question.

You can implement context menu with ContextMenuHandler, I know.
But sometimes, if you perform a right click, there are some additional entries in context menu like "Print..." and so on.
I searched through (J)Cef, but only can find IDs (cef_menu_id_t) for them.

In some comments (above context menu methods) I can find sth like "if returned false, it will be handled by default implementation".
My question. WHERE I can find those implementations? Where are localization strings for those entries? Where I can disable those entries?

Thanks ;)
edominic
Mentor
 
Posts: 82
Joined: Fri Mar 13, 2015 6:46 am

Re: Contextmenu: Additional entries

Postby magreenblatt » Thu Aug 13, 2015 9:40 am

You can remove/modify the entries via the CefMenuModel passed to CefContextMenuHandler::OnBeforeContextMenu.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Contextmenu: Additional entries

Postby edominic » Fri Aug 14, 2015 1:20 am

So I always have to check, if there are already some entries and then remove them?

Unfortunately, you forgot to answer my other question.
1.) Where I can find implementations (functions) of those entries? Somewhere in cef/chromium there must be implementation/functions of those entries.

I need to know, how "Print..." entry is handled in cef.
If I add a Shortcut for printing (cmd/strg + p) and open a pdf in cef and press this combination, nothing happens although there is "Print..." in context menu and this works.
So how I get the print dialog with a shortcut? In code, I write
Code: Select all
cefBrowser.print()
but nothing happens, or how do I get the print dialog?
edominic
Mentor
 
Posts: 82
Joined: Fri Mar 13, 2015 6:46 am

Re: Contextmenu: Additional entries

Postby magreenblatt » Fri Aug 14, 2015 8:20 am

Printing is triggered via CefBrowserHost::Print().
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Contextmenu: Additional entries

Postby edominic » Mon Aug 17, 2015 3:00 am

magreenblatt wrote:You can remove/modify the entries via the CefMenuModel passed to CefContextMenuHandler::OnBeforeContextMenu.


I think, the entries will be added after java-side OnBeforeContextMenu. They will be added in C++, so the only possibility is to remove them in C++?
edominic
Mentor
 
Posts: 82
Joined: Fri Mar 13, 2015 6:46 am

Re: Contextmenu: Additional entries

Postby magreenblatt » Mon Aug 17, 2015 11:18 am

edominic wrote:
magreenblatt wrote:You can remove/modify the entries via the CefMenuModel passed to CefContextMenuHandler::OnBeforeContextMenu.


I think, the entries will be added after java-side OnBeforeContextMenu. They will be added in C++, so the only possibility is to remove them in C++?

No, they are added before. If you cannnot modify the CefMenuModel via the Java OnBeforeContextMenu callback then it's a bug.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Contextmenu: Additional entries

Postby edominic » Tue Aug 18, 2015 12:41 am

If they are added before, then there must be a bug.

Because
1) Entries are at the end of context menu
2) Even if I add
Code: Select all
model.clear()
at first call on method, there are visible

Some screenshots:
last three entries:
Image

Last entry:
Image

Complete menu (opened pdf in a seperate js-window):
Image
edominic
Mentor
 
Posts: 82
Joined: Fri Mar 13, 2015 6:46 am

Re: Contextmenu: Additional entries

Postby magreenblatt » Tue Aug 18, 2015 10:22 am

Ah, the "Search with Google" and following entries. They're likely coming from the system somewhere (e.g. the registry) but I agree that it would be nice to get rid of them. Do they show up in the cefclient sample application as well?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Contextmenu: Additional entries

Postby edominic » Wed Aug 19, 2015 12:37 am

Do you mean jcef sample app, or "normal" cefclient sample app?
in jcef sample app yes they do:

Image
Image

in normal cefclient I have to check, don't have binaries on my drive any more
edominic
Mentor
 
Posts: 82
Joined: Fri Mar 13, 2015 6:46 am


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 135 guests