WebViewGadget: set URL

Just starting out? Need help? Post your questions and find answers here.
Marc56us
Addict
Addict
Posts: 1600
Joined: Sat Feb 08, 2014 3:26 pm

WebViewGadget: set URL

Post by Marc56us »

Hi,

How to set URL in new WebViewGadget ?
SetGadgetText set text webpage source.
I do this with success, But I think there's something simpler ?

Code: Select all

OpenWindow   (0,  0,  0, 1000, 800,"", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) 
WebViewGadget(0, 10, 10,  980, 780)

*Buf = ReceiveHTTPMemory("https://www.purebasic.fr")

SetGadgetText(0, PeekS(*Buf, MemorySize(*Buf), #PB_UTF8 | #PB_ByteLength))

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Did I miss something on the forum?
:wink:
Fred
Administrator
Administrator
Posts: 18351
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: WebViewGadget: set URL

Post by Fred »

WebViewGadget() is meant to do web based UI, not to navigate on the web. You can use the WebGadget() for this (with the #PB_Web_Edge flag if you want to use the new WebView2 engine).
User avatar
the.weavster
Addict
Addict
Posts: 1581
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: WebViewGadget: set URL

Post by the.weavster »

Fred wrote: Sat Dec 23, 2023 12:51 pm WebViewGadget() is meant to do web based UI, not to navigate on the web.
Even so I'd want to be able to do:

Code: Select all

WebViewGadget(0, 10, 10,  980, 780)
SetGadgetText(0, "file:///index.html")
pamen
Enthusiast
Enthusiast
Posts: 193
Joined: Sat Dec 31, 2022 12:24 pm
Location: Cyprus
Contact:

Re: WebViewGadget: set URL

Post by pamen »

In my humble opinion it is very important, not only simpler, to be able to load pages and at the same time execute JS, use callbacks for links/navigation all at the same time.
My example:
I have an email client, which must remove and add parts of html structure (done via text, not DOM), prevent scripts from running or run scripts, inject scripts and retrieve both HTML and text from a HTML DOM.
This is possible in multiplatform using javascript - works now fine with IE/GTK/Safari - although involves some extra code for each platform.
Additionally - HTML file can be opened form a file or downloaded via network, depends on situation.

In any case, at least setting a URL (local or remote) and JS callbacks (with numeric and string returns) in a component which displays HTML is a must for many uses.
I still don't get, why there are two components...
S.T.V.B.E.E.V.
Fred
Administrator
Administrator
Posts: 18351
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: WebViewGadget: set URL

Post by Fred »

It's 2 different component because I don't want to be tied to a specific backend forever, for example we could use Sciter which is not a webbrowser. That way we have a specific web UI component which is more limited than a full blow web gadget(). That said I will add missing features if needed.
pamen
Enthusiast
Enthusiast
Posts: 193
Joined: Sat Dec 31, 2022 12:24 pm
Location: Cyprus
Contact:

Re: WebViewGadget: set URL

Post by pamen »

Understood, thank you Fred.
I used sciter - it is good as well and much leaner than a browser - better for new app design.

But full blown WebGadget main shortcoming was before exactly that, which can be done either by using VIEW component with full functionality and rendering or enhancements to WebGadget (more compatible with what people did in the last 10 years)

- no ability to access keys (CTRL-N will open a browser!), loading behavior (async, stop), intercept <a> clicks (Click on an email will fire email client, not possible to intercept)
- no ability to run JS with numeric and string returns
S.T.V.B.E.E.V.
Post Reply