Including a wxWebView notebook page in my app

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
EddieM
Experienced Solver
Experienced Solver
Posts: 81
Joined: Mon Oct 19, 2020 3:27 pm

Including a wxWebView notebook page in my app

Post by EddieM »

Hi,
I have included a wxWebView in a notebook page in my app. It is basically just the webview sample inside a wxPanel instead of a wxFrame. It works fine as expected just like the sample app.
However, when I browse to a page and double click on an image I get the large image as with other browsers but cannot right click on it to get a context menu to save the image. I could add a button to do a wxWebRequest on the identified image but that seems clunky next to a simple context menu.
My problem is how to I go about programming the context menu and identify the image object for saving. I assume I need to do this in the webkitgtk backend? I see some links to using Java script but nothing to tell me how to use it. I don’t know anything about Java script or web programming, etc.
Can someone point me to a good beginner tutorial for programming/using with WebKit?
I’m on Linux using the WebKitGTK.
Thanks,
Eddie
The most wasted of all days is one without laughter.
~e.e. cummings.
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Including a wxWebView notebook page in my app

Post by doublemax »

Did you disable the context menu? Both under Linux and Windows, when i rightclick an image on a webpage, i get an option to save it.

webview-mint20.jpg
Use the source, Luke!
EddieM
Experienced Solver
Experienced Solver
Posts: 81
Joined: Mon Oct 19, 2020 3:27 pm

Re: Including a wxWebView notebook page in my app

Post by EddieM »

Yes, I have enabled context menus.
That said, I went back and clicked on a different image, like a logo image, and I do get a context menu with an option to save. I never tried that. I never needed the website logo.
That means that the image in the body of the web page must disable the option internally. That is a different problem.
Let me go think about that some.
Eddie
The most wasted of all days is one without laughter.
~e.e. cummings.
EddieM
Experienced Solver
Experienced Solver
Posts: 81
Joined: Mon Oct 19, 2020 3:27 pm

Re: Including a wxWebView notebook page in my app

Post by EddieM »

Yes, it does seem to be the images on the site are disabled from download or at least the context menu. images on other sites do give the menu as expected. The copy image does work as it let me paste it into a graphics draw app. The save-as option however does not ever provide a save dialog to save the image on any site. I'm still not there. I'm testing from the unmodified WebView Sample.
So that does bring me back to how do I figure out what functionality the webview backend provides? How do I interface to it? Is there something else I need to code, like a pointer to a dialog and somehow provide it to the back end? Or maybe listen for an process an event?
I just don't know enough to know what to look for or what question to ask. I'm doing this just to keep my brain active (I'm old.) so learning new stuff and figuring out how to use it is good. I just don't know where to start.
Eddie
The most wasted of all days is one without laughter.
~e.e. cummings.
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Including a wxWebView notebook page in my app

Post by doublemax »

You should test the sites that don't work in a standalone browser. Many websites actively try to prevent images from easy downloading by putting invisible elements on top of the images to hijack the mouse events.
Use the source, Luke!
EddieM
Experienced Solver
Experienced Solver
Posts: 81
Joined: Mon Oct 19, 2020 3:27 pm

Re: Including a wxWebView notebook page in my app

Post by EddieM »

By standalone browser you mean like my FireFox browser? What would I look for?
Is there any way around it short of parsing the page source and getting the image url? I know how to do that. :)
I guess I should say I’m don’t want to do anything Illegal. I’m just doing this to learn.
Eddie
The most wasted of all days is one without laughter.
~e.e. cummings.
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Including a wxWebView notebook page in my app

Post by doublemax »

EddieM wrote: Fri Mar 31, 2023 10:04 pm By standalone browser you mean like my FireFox browser? What would I look for?
Just check if you can download the image with the right click menu.
Use the source, Luke!
EddieM
Experienced Solver
Experienced Solver
Posts: 81
Joined: Mon Oct 19, 2020 3:27 pm

Re: Including a wxWebView notebook page in my app

Post by EddieM »

No. They so not behave the same. In the regular browser I click the "Save Image As" and get the save-as dialog that works. With the WebView Sample code I never get the save-as dialog though the save address and copy image do work.
Which makes me ask "What is missing?" Am I supposed to be reacting to an event? Is some setup to the webkit backend not done?
Eddie
The most wasted of all days is one without laughter.
~e.e. cummings.
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Including a wxWebView notebook page in my app

Post by doublemax »

EddieM wrote: Fri Mar 31, 2023 11:44 pm No. They so not behave the same. In the regular browser I click the "Save Image As" and get the save-as dialog that works. With the WebView Sample code I never get the save-as dialog though the save address and copy image do work.
Can you share the site you're testing with?
Which makes me ask "What is missing?" Am I supposed to be reacting to an event? Is some setup to the webkit backend not done?
Sorry, no idea.
Use the source, Luke!
EddieM
Experienced Solver
Experienced Solver
Posts: 81
Joined: Mon Oct 19, 2020 3:27 pm

Re: Including a wxWebView notebook page in my app

Post by EddieM »

As far as I have tried i do not see a save-as dialog on any site. Try:
https://postalmuseum.si.edu/object/npm_1998.2008.779
I am writing a stamp album page generator and am interested in stamp images. I have visited colnect.com, mysticstamp.com and others. Even doesn't work on amazon.com.
Eddie
The most wasted of all days is one without laughter.
~e.e. cummings.
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Including a wxWebView notebook page in my app

Post by doublemax »

So you do get the "Save image as...", but you don't get a dialog to save the file?

That really looks like there is an event missing that needs to be handled. Try asking on the https://groups.google.com/g/wx-users where you can reach the core developers, or open an issue at: https://github.com/wxWidgets/wxWidgets/issues
Use the source, Luke!
EddieM
Experienced Solver
Experienced Solver
Posts: 81
Joined: Mon Oct 19, 2020 3:27 pm

Re: Including a wxWebView notebook page in my app

Post by EddieM »

That is right. i get the popup menu asking to saveAs/CopyIImage/SaveAddress. the copy image copies an image into the clip board tha can be pasted into a graphics app. The Save address adds the url to the clip board. but the Save As doesn't do anything.
I will ask on the google site.
Thanks
Eddie
The most wasted of all days is one without laughter.
~e.e. cummings.
Post Reply