Page 3 of 7

Re: PB.Ex WebGadget (Windows) (WebKit)

Posted: Tue May 21, 2019 7:15 am
by RSBasic
Good morning

Yes, that's correct. You can only call PB procedure, pass parameter (JS -> PB), but don't return a return value (PB -> JS).

Re: PB.Ex WebGadget (Windows) (WebKit)

Posted: Tue May 21, 2019 8:35 am
by captain_skank
Morning,

First up thanks and congrats on all the work you've done recently, it is anexcellent body of work.

When i run this it displays a blank window, pauses and the quits with 'debugged executable quit unexpectedly'

I'm running it on windows 10 x64 v1809 the processor is a AMD FX8370 and i've tried with PB versions 5.70 and 5.71.

Any idea what i'm doing wrong ?

cheers

Re: PB.Ex WebGadget (Windows) (WebKit)

Posted: Tue May 21, 2019 8:40 am
by HanPBF
@RSBasic

Aha!!!! Thanks a lot for the quick answer!!!

So, the way to work here is calling procedure (PureBasic) from function (JavaScript) and let PureBasic send the answer asynchronously to JavaScript.
Which is more effort to manage but possible via exp. GUID match.

And I guess that internally there happens some messaging like calls when embedding CEF browser.

Now after this answer I still consider Your work here what it simply is: great :D

Thanks a lot!!!

Re: PB.Ex WebGadget (Windows) (WebKit)

Posted: Tue May 21, 2019 8:42 am
by HanPBF
@captain_skank

That happened to me when source/compiled exe was not in same folder as CEF things.

Re: PB.Ex WebGadget (Windows) (WebKit)

Posted: Tue May 21, 2019 8:46 am
by captain_skank
@HanPBF

Yep your right :) sorry :oops:

Re: PB.Ex WebGadget (Windows) (WebKit)

Posted: Tue May 21, 2019 9:51 am
by HanPBF
Here is the code for JavaScript using JSON:

Code: Select all

var CEF = {
	Callbacks:{/*guid*/}
};

procedure resolveWebGadgetEx(GUID.s, P.s)	
	ExecuteWebGadgetExJavaScript(PBWebGadgetEx, "CEF.Resolves['" + GUID + "'](" + P + ")", @OutputWebGadgetEx, @ErrorOutputWebGadgetEx)	
endProcedure

CEF.call = (fun, arg={}) => {	// async call -> return value via resolve used
	let R = new Promise((resolve, reject) => {
		arg.GUID = JS.guid()
		
		CEF.Resolves[arg.GUID]	= resolve
		
		PB.call.call(null, fun, JSON.stringify(arg))
	});
	
	return R
};

CEF.callS = (fun, arg) => {		// sync call -> no return value used
	PB.call.call(null, fun, JSON.stringify(arg))
};
Here the PureBasic code to handle this (example with LibXL):

Code: Select all

structure ArgWebGadgetEx
	GUID	.s
endStructure

structure saveExcelWorkbookArgWG extends ArgWebGadgetEx	
	WB 				.i
	FilePath	.s
endStructure

procedure saveExcelWorkbookWG(*P)
	var P.s	= PeekS(*P)
	var J = ParseJSON(#PB_Any, P)
	var Arg.saveExcelWorkbookArgWG
	
	ExtractJSONStructure(JSONValue(J), @Arg, saveExcelWorkbookArgWG)
		
	var R = bool(saveExcelWorkbook(Arg\WB, Arg\FilePath) = 0)
		
	resolveWebGadgetEx(Arg\GUID, Str(R))
endProcedure

So, using it in JS could be done this way:

Code: Select all

async free(){
		CEF.callS('freeExcelWorkbook', {WB:this.Nr})  // no return value needed...
	}
	
	async save(FilePath){
		return await CEF.call('saveExcelWorkbook', {WB:this.Nr, FilePath})
	}


Re: PB.Ex WebGadget (Windows) (WebKit)

Posted: Tue May 21, 2019 9:56 am
by RSBasic
Nice example Image

Re: PB.Ex WebGadget (Windows) (WebKit)

Posted: Fri Jul 12, 2019 8:59 pm
by RSBasic
PB.Ex WebGadget 1.0.7.0 has been released.

Changelog:
  • Added: SetWebGadgetExAttribute()
  • Added: #PB_Web_Zoom for GetWebGadgetExAttribute()
  • Added: #PB_Web_Zoom for SetWebGadgetExAttribute()

Re: PB.Ex WebGadget (Windows) (WebKit)

Posted: Mon Jul 22, 2019 1:16 pm
by RSBasic
PB.Ex WebGadget 1.0.8.0 has been released.

Changelog:
  • Added: SetWebGadgetExSetUserAgent()

Re: PB.Ex WebGadget (Windows) (WebKit)

Posted: Wed Jul 24, 2019 7:02 pm
by firace
Thanks for sharing, very interesting (although I haven't had a chance to give it a try yet)

Re: PB.Ex WebGadget (Windows) (WebKit)

Posted: Thu Jul 25, 2019 10:21 am
by Thorium
Great work, thank you for sharing.

Re: PB.Ex WebGadget (Windows) (WebKit)

Posted: Thu Jul 25, 2019 2:21 pm
by Thorium
I have a request: Please add option to change the path of the WebKit installation.
Currently it needs to be in the same directory as the application executable. It would be nice if we can specify a path, so applications can share one installation easily.

Re: PB.Ex WebGadget (Windows) (WebKit)

Posted: Thu Jul 25, 2019 3:01 pm
by RSBasic
I tested this: https://stackoverflow.com/questions/556 ... r-55683969

But it's not working. :(

Re: PB.Ex WebGadget (Windows) (WebKit)

Posted: Mon Aug 05, 2019 2:09 pm
by RSBasic
PB.Ex WebGadget 1.0.9.0 has been released.

Changelog:
  • Added: #PB_Web_BlockPopupMenu for SetWebGadgetExAttribute()

Re: PB.Ex WebGadget (Windows) (WebKit)

Posted: Sat Aug 31, 2019 3:15 am
by zikitrake
I just tried the latest version and it goes like silk!

Is it currently possible to define a proxy? (anonymous and/or with user:pass)