Page 1 of 1

[Done] PB6.10B3: WebViewGadget does not work anymore

Posted: Sat Jan 20, 2024 1:21 pm
by Kiffi
Sample code (from here) worked with B1 (and using the UseDialogWebGadget() - workaround with B2).

With B3, the window is empty:

Code: Select all

Html$ =  ~"<button id=\"increment\">Tap me</button>\n"+
~"<div>You tapped <span id=\"count\">0</span> time(s).</div>\n"+
~"<button id=\"compute\">Compute</button>\n"+
~"<div>Result of computation: <span id=\"compute-result\">0</span></div>\n"+
~"<script>\n"+
~"  const [incrementElement, countElement, computeElement, "+
~"computeResultElement] =\n"+
~"    document.querySelectorAll(\"#increment, #count, #compute, "+
~"#compute-result\");\n"+
~"  document.addEventListener(\"DOMContentLoaded\", () => {\n"+
~"    incrementElement.addEventListener(\"click\", () => {\n"+
~"      window.increment().then(result => {\n"+
~"        countElement.textContent = result.count;\n"+
~"      });\n"+
~"    });\n"+
~"    computeElement.addEventListener(\"click\", () => {\n"+
~"      computeElement.disabled = true;\n"+
~"      window.compute(6, 7).then(result => {\n"+
~"        computeResultElement.textContent = result;\n"+
~"        computeElement.disabled = false;\n"+
~"      });\n"+
~"    });\n"+
~"  });\n"+
~"</script>";
    

Procedure IncrementJS(Json$)
  Static i
  Debug "IncrementJS "+Json$
  i+1
  ProcedureReturn UTF8(~"{ \"count\": "+Str(i)+ "}")
EndProcedure


Procedure ComputeJS(Json$)
  Debug "ComputeJS "+Json$
  ProcedureReturn UTF8(~"150")
EndProcedure


OpenWindow(0, 100, 100, 400, 400, "Hello", #PB_Window_SystemMenu)

WebViewGadget(0, 0, 0, 400, 400)
SetGadgetText(0, Html$)
  
BindWebViewCallback(0, "increment", @IncrementJS())
BindWebViewCallback(0, "compute", @ComputeJS())

Repeat 
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow

// Moved from "Bugs - Windows" to "Coding Questions" (Kiffi)

Re: PB6.10B3: WebViewGadget does not work anymore

Posted: Sat Jan 20, 2024 1:23 pm
by Fred
You need to use setgadgetitemtext() now, like the web gadget()

Re: PB6.10B3: WebViewGadget does not work anymore

Posted: Sat Jan 20, 2024 1:29 pm
by Kiffi
Whow, that was fast! :shock: :D
Fred wrote: Sat Jan 20, 2024 1:23 pm You need to use setgadgetitemtext() now, like the web gadget()
It works now. Thanks for the tip! Image