Page 1 of 1

WebViewGadget: SetGadgetText is not displaying content

Posted: Thu Mar 14, 2024 9:05 am
by Marco2007
Hello everyone,

maybe a stupid question: Why isn't purebasic.com displayed, after pressing the button?

This is just a demo code:

Code: Select all

If OpenWindow(0, 200, 200, 800, 840, "")
  ButtonGadget(0, 0, 0, 200, 40, "Press")
  WebViewGadget(1, 0, 40, 800, 800)
  SetGadgetText(1, "http://www.google.com")
EndIf 

Repeat 
  event=WaitWindowEvent()
    Select event 
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 0 
            Debug "ok"
            SetGadgetText(1, "https://www.purebasic.com/") : Delay(5000)
            Debug "ok"
            SetGadgetText(1, "http://www.w3schools.com")
        EndSelect 
    EndSelect 
  Until Event=#PB_Event_CloseWindow

Re: WebViewGadget: SetGadgetText is not displaying content

Posted: Thu Mar 14, 2024 9:12 am
by mk-soft
Never block the event loop -> Delay(5000)

Re: WebViewGadget: SetGadgetText is not displaying content

Posted: Thu Mar 14, 2024 9:29 am
by Marco2007
Delay is just instead of a procedure to demonstrate. I do have problems doing this (without delay).

Another demo:

Code: Select all

Procedure test()
For i=1 To 200000000
Next 
EndProcedure 

If OpenWindow(0, 200, 200, 800, 840, "")
  ButtonGadget(0, 0, 0, 200, 40, "Press")
  WebViewGadget(1, 0, 40, 800, 800)
  SetGadgetText(1, "http://www.google.at")
EndIf 

Repeat 
  event=WaitWindowEvent()
    Select event 
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 0 
            Debug "ok"
            SetGadgetText(1, "https://www.purebasic.com/") : test()
            Debug "ok"
            SetGadgetText(1, "http://www.w3schools.com")
        EndSelect 
    EndSelect 
  Until Event=#PB_Event_CloseWindow


I thought:
1) purebasic will be displayed
2) test() will be called
3) w3schools will be displayed

Not? How to do that? Thread?

Re: WebViewGadget: SetGadgetText is not displaying content

Posted: Thu Mar 14, 2024 9:54 am
by mk-soft
Exactly the same as with Delay.
The events must be processed. Otherwise the WebViewGadget will not be updated.
It is not possible from Thread, as the events must also be processed.
However, this is not a problem, as the WebView internally processes everything in Thread in the background anyway.

Re: WebViewGadget: SetGadgetText is not displaying content

Posted: Thu Mar 14, 2024 10:27 am
by Marco2007
Hmmm ... thx! 😊

The strange thing with the code I'm using: The first one will be displayed and the second one not ... 😤
I thought, I could demostrate the issue with the code above, but your explanation sounds plausible.

Re: WebViewGadget: SetGadgetText is not displaying content

Posted: Thu Mar 14, 2024 1:28 pm
by infratec
You can do it with a timer for a demo.