Updating WebGadget URL then refreshing
Posted: Tue Nov 19, 2024 8:06 pm
I'm not sure what I need to change in order to make this work. I'm using PB 6.00 Windows 64-bit and I note the F1 help confirms that SetGadgetText can be used with the web gadget to change the URL, furthermore that SetGadgetState(x, #PB_Web_Refresh) will refresh the gadget.
Two aspects that don't work :
1. When I enter a new URL and click the Update button, it requires two separate clicks before the change takes effect (I can see the browser refresh but it only refreshes same web page)
2. If I set the string gadget to an empty initial value (line 3), it won't ever work, despite what I later enter.
Two aspects that don't work :
1. When I enter a new URL and click the Update button, it requires two separate clicks before the change takes effect (I can see the browser refresh but it only refreshes same web page)
2. If I set the string gadget to an empty initial value (line 3), it won't ever work, despite what I later enter.
Code: Select all
OpenWindow(0,0,0,800,800,"", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
StringGadget(2,5,5,750,25,"https://time.is")
ButtonGadget(3,5,35,165,25, "Update URL to Web Gadget")
If WebGadget(1,0,70,WindowWidth(0), WindowHeight(0) - 80,GetGadgetText(2))
Debug "WebGadget created successfully"
EndIf
; ** Below courtesy of Rashad to suppress script messages
Browser.IWebBrowser2 = GetWindowLongPtr_(GadgetID(1), #GWL_USERDATA)
Browser\put_Silent(1)
Repeat
event = WaitWindowEvent()
Select event
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
Select EventGadget()
Case 3
Debug "Updating URL"
Debug "> " + GetGadgetText(2)
If GetGadgetText(2) <> ""
SetGadgetText(1, GetGadgetText(2))
SetGadgetState(1, #PB_Web_Refresh)
EndIf
EndSelect
EndSelect
ForEver