Webview2 control - Chromium browser for Purebasic (Windows) [Jan 1, 2024]

Everything else that doesn't fall into one of the other PB categories.
Justin
Addict
Addict
Posts: 948
Joined: Sat Apr 26, 2003 2:49 pm

Re: Webview2 control - Chromium browser for Purebasic (Windows) [Jan 1, 2024]

Post by Justin »

This should fix the *browser issue:

Code: Select all

Procedure IfThisLinkOk(Passed_suri$)  ; vm
	Protected.BROWSER *browser
	
  Debug "1 LINK Procedure IfThisLinkOk = " + Passed_suri$  ; vm"
  ThisLinkItemOk = #False 
  ResetList(ThisLinkList())
  While NextElement(ThisLinkList())
    CurrentElementContent$ = ThisLinkList() 
;    Debug "IfThisLinkOk  CurrentElementContent$" + CurrentElementContent$
    Position = FindString(Passed_suri$, CurrentElementContent$ , 0 ) 
    If Position > 0     
      Debug "ThisLinkItemOk = #True  " + Passed_suri$ 
      ThisLinkItemOk = #True 
    EndIf  ;  Greater than 0 == Yes its a Hit 
  Wend
  
    If ThisLinkItemOk = #False 
; GO TO:  https://kidsafebrowser.us/Warning-UnSafe-Site.html
      *browser = tab_GetCurrentBrowser()
      If *browser
      	*browser\core\Navigate("http://kidsafebrowser.us/Warning-UnSafe-Site.html")  ; 
      EndIf 

    EndIf 
EndProcedure ; IfThisLinkOk()  
With enableexplicit you will need to declare the rest of your local procedure variables using Protected
If the url is the result of SourceChanged event you will need to use the location.replace() method i posted before, otherwise you can't use Go Back navigation because it returns to the unwanted url.
vmars316
Enthusiast
Enthusiast
Posts: 474
Joined: Fri Jun 29, 2012 12:24 am
Contact:

Re: Webview2 control - Chromium browser for Purebasic (Windows) [Jan 1, 2024]

Post by vmars316 »

Thanks Again Justin ,
It took me a while to fit it all together ,
but all is working perfectly .
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
vmars316
Enthusiast
Enthusiast
Posts: 474
Joined: Fri Jun 29, 2012 12:24 am
Contact:

Re: Webview2 control - Chromium browser for Purebasic (Windows) [Jan 1, 2024]

Post by vmars316 »

Hi Justin ,
Shucks , thought I had it licked :
Turns out , the Address-Bar doesn't get updated .
I'm thinking here is a promising spot to update it :

Code: Select all

	sender\get_Source(@uri)
	If uri
	  suri = PeekS(uri)
	  Debug "Procedure core_NavigationCompleted  suri = " + suri
		str_FreeCoMemString(uri)
	EndIf
in here :

Code: Select all

Procedure core_NavigationCompleted(this.IWV2EventHandler, sender.ICoreWebView2, args.ICoreWebView2NavigationCompletedEventArgs)
	Protected.i uri, title
	Protected.s suri, stitle, host, iconUrl
	Protected.BROWSER *browser, *currBrowser
	  ;Debug "Procedure core_NavigationCompleted() = " + suri + "  Passed_suri$ = " + Passed_suri$  

	this\LockMutex()
	*browser = this\GetContext()
	
	sender\get_Source(@uri)
	If uri
	  suri = PeekS(uri)
	  Debug "Procedure core_NavigationCompleted  suri = " + suri
		str_FreeCoMemString(uri)
	EndIf
	
	host = GetURLPart(suri, #PB_URL_Site)
	If host
		
		;Get favicon	
; 		*browser\core\ExecuteScript(#FAVICON_SCRIPT_GET_ICON, wv2_EventHandler_New(@favicon_ScriptExecuted(), *browser))
	EndIf 
	
	sender\get_DocumentTitle(@title)
	If title
	  stitle = PeekS(title)
	  Debug "Procedure core_NavigationCompleted  stitle = " + stitle
		str_FreeCoMemString(title)
	EndIf 
	
; 	url_Edit_SetText(app\url, suri)
	
	If stitle = ""
		stitle = "New tab"
	EndIf 
	
	tabCtrl_SetItemText2(app\tab, browser_GetTabIndex(*browser), stitle, #TAB_MAX_ITEM_WIDTH)

	this\UnlockMutex()
EndProcedure ; core_NavigationCompleted
How can I do that ?
Thanks
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
Justin
Addict
Addict
Posts: 948
Joined: Sat Apr 26, 2003 2:49 pm

Re: Webview2 control - Chromium browser for Purebasic (Windows) [Jan 1, 2024]

Post by Justin »

The address bar is updated in the core_SourceChanged() event, search for the core_SourceChanged() procedure in the last Ohm.pb version at github to see how it's done:
https://github.com/omegakode/PBWebview2 ... ser/Ohm.pb
vmars316
Enthusiast
Enthusiast
Posts: 474
Joined: Fri Jun 29, 2012 12:24 am
Contact:

Re: Webview2 control - Chromium browser for Purebasic (Windows) [Jan 1, 2024]

Post by vmars316 »

Ah perfect , Thanks Justin
Looks like I had commented out this puppy:

Code: Select all

url_Edit_SetText(app\url, suri) 
vmars.us Win11 x64 , Martin Guitar 000-16 (1995)
"All things in moderation , except for love and forgiveness."
infratec
Always Here
Always Here
Posts: 7576
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Webview2 control - Chromium browser for Purebasic (Windows) [Jan 1, 2024]

Post by infratec »

Made my stuff PB 6.10 compatible.

I had to add many CompilerIfs :wink:

But it seams that it works better (smother) in 6.04 then in 6.10 or it is my PC.
Justin
Addict
Addict
Posts: 948
Joined: Sat Apr 26, 2003 2:49 pm

Re: Webview2 control - Chromium browser for Purebasic (Windows) [Jan 1, 2024]

Post by Justin »

Hi,

The next update will make things much easier, for now it uses the api control but i'll try to integrate the new WebGadget.
I didn't notice any difference, a very good thing of 6.10 is that the dll can be linked statically.

Here is a sneak preview with theme transitions in 6.10:
Image
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Re: Webview2 control - Chromium browser for Purebasic (Windows) [Jan 1, 2024]

Post by ricardo »

Hi,

I downloaded from GitHub, but i tried to run any example, it does not find some files

Code: Select all

XIncludeFile "math.pb"
XIncludeFile "Unsigned.pb"
XIncludeFile "stream.pb"
XIncludeFile "resource.pb"
XIncludeFile "json.pb"
XIncludeFile "keyboard.pb"
XIncludeFile "enum.pb"
ARGENTINA WORLD CHAMPION
Justin
Addict
Addict
Posts: 948
Joined: Sat Apr 26, 2003 2:49 pm

Re: Webview2 control - Chromium browser for Purebasic (Windows) [Jan 1, 2024]

Post by Justin »

Hi,

it's fixed now. I no longer update this repo, i will put the updated pb Webview2 headers only in another one.
User avatar
useful
Enthusiast
Enthusiast
Posts: 402
Joined: Fri Jul 19, 2013 7:36 am

Re: Webview2 control - Chromium browser for Purebasic (Windows) [Jan 1, 2024]

Post by useful »

Justin wrote: Thu Feb 15, 2024 10:45 pm
I didn't notice any difference, a very good thing of 6.10 is that the dll can be linked statically.
Where can I read about this feature?
Dawn will come inevitably.
Justin
Addict
Addict
Posts: 948
Joined: Sat Apr 26, 2003 2:49 pm

Re: Webview2 control - Chromium browser for Purebasic (Windows) [Jan 1, 2024]

Post by Justin »

With the new linker it's easier to import static libraries.
For example in WebView2Loader.pbi if you change:

Import "x64\WebView2Loader.lib"

to

Import "x64\WebView2LoaderStatic.lib"

you don't need to ship WebView2Loader.dll with the exe, it is compiled with the executable.
User avatar
useful
Enthusiast
Enthusiast
Posts: 402
Joined: Fri Jul 19, 2013 7:36 am

Re: Webview2 control - Chromium browser for Purebasic (Windows) [Jan 1, 2024]

Post by useful »

It's obvious about lib, but I read about dll in your message, I was surprised and therefore asked a question :)
Justin wrote: Thu Feb 15, 2024 10:45 pm ... dll can be linked statically.
Dawn will come inevitably.
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Re: Webview2 control - Chromium browser for Purebasic (Windows)

Post by ricardo »

infratec wrote: Fri Nov 10, 2023 7:40 am Is WebView2 runtime installed?
In Win 10 this should be the cas if your PC is up to date.
But check it in the software control paneL
It is called: Microsoft Edge WebView2 runtime

If not, you have to install it.

Oh, and if you use PB x64 you have to copy the WebView2Loader.dll from the x64 subdirectory.
I run WebView2Gadget.pbi using PB 6.11 and no window was displayed. I have the runtime installed.
ARGENTINA WORLD CHAMPION
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Re: Webview2 control - Chromium browser for Purebasic (Windows) [Jan 1, 2024]

Post by ricardo »

Its possible using this gadget to navigate to some website and use javascript to interact?

Thanks in advance!!
ARGENTINA WORLD CHAMPION
User avatar
Erolcum
User
User
Posts: 51
Joined: Fri Jun 07, 2024 10:45 am
Location: Turkiye
Contact:

Re: Webview2 control - Chromium browser for Purebasic (Windows) [Jan 1, 2024]

Post by Erolcum »

I think, you can use webviewgadget in PB :
https://www.purebasic.com/documentation ... adget.html
You may visit my new Purebasic blog here..
:arrow: https://erolcum-github-io.translate.goo ... r_pto=wapp
Post Reply