WebViewGadget: SetGadgetText is not displaying content

Just starting out? Need help? Post your questions and find answers here.
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

WebViewGadget: SetGadgetText is not displaying content

Post 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
Last edited by Marco2007 on Thu Mar 14, 2024 9:57 am, edited 1 time in total.
PureBasic for Windows
User avatar
mk-soft
Always Here
Always Here
Posts: 6201
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: WebViewGadget: SetGadgetText is not displaying content

Post by mk-soft »

Never block the event loop -> Delay(5000)
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Re: WebViewGadget: SetGadgetText is not displaying content

Post 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?
Last edited by Marco2007 on Thu Mar 14, 2024 9:57 am, edited 1 time in total.
PureBasic for Windows
User avatar
mk-soft
Always Here
Always Here
Posts: 6201
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: WebViewGadget: SetGadgetText is not displaying content

Post 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.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Marco2007
Enthusiast
Enthusiast
Posts: 648
Joined: Tue Jun 12, 2007 10:30 am
Location: not there...

Re: WebViewGadget: SetGadgetText is not displaying content

Post 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.
PureBasic for Windows
infratec
Always Here
Always Here
Posts: 7575
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: WebViewGadget: SetGadgetText is not displaying content

Post by infratec »

You can do it with a timer for a demo.
Post Reply