Possible Bug with WebGadget Scrolling
Posted: Wed Jan 07, 2009 4:38 am
Sometimes GetGadgetAttribute(#webGadget, #PB_Web_ScrollY) seems to report the vertical scroll Y position as zero when it is not and sometimes SetGadgetAttribute(#webGadget, #PB_Web_ScrollY, <posn>) fails to set the scroll position. These problems may also occur with horizontal scrolling but I have not tested to see.
If you run the program below and carefully watch the DEBUG window, you will see how the scroll Y position for some websites increases monotonically whilst for others it is always reported as zero. The website http://www.3dgw.com also seems to have problems with setting the scroll position in addition to retrieving it.
The situation is far worse if the #PB_Web_Mozilla flag is used with WebGadget() as scrolling does not then seem to work at all programatically.
Here is a demo that regularly changes the scroll position and then attempts to retrieve and display it:
If you run the program below and carefully watch the DEBUG window, you will see how the scroll Y position for some websites increases monotonically whilst for others it is always reported as zero. The website http://www.3dgw.com also seems to have problems with setting the scroll position in addition to retrieving it.
The situation is far worse if the #PB_Web_Mozilla flag is used with WebGadget() as scrolling does not then seem to work at all programatically.
Here is a demo that regularly changes the scroll position and then attempts to retrieve and display it:
Code: Select all
; Ensure the DEBUG window is visible. It will display Y values
; Notice that for some websites the scroll Y position is wrongly reported
DataSection
Data.s "www.purebasic.com" ; OK
Data.s "uk.ask.com" ; Problem with get scroll Y posn
Data.s "www.purebasic.com" ; OK
Data.s "www.3dgw.com" ; Problem with set/get scroll Y posn
Data.s "www.purebasic.com" ; OK
Data.s "www.five.tv" ; Problem with get scroll Y posn
Data.s "" ; End
EndDataSection
Enumeration
#winMain
#webGadget
EndEnumeration
Global url$, timer
Procedure Tick()
; Inovked each time the timer ticks
; Changes web gadget Y scroll position and then reports it
Static counter = 0
counter + 1
If counter%4 = 0
Read.s url$: If url$="": End: EndIf
SetGadgetText(#webGadget, url$)
EndIf
SetGadgetAttribute(#webGadget, #PB_Web_ScrollY, counter*20)
Debug GetGadgetAttribute(#webGadget, #PB_Web_ScrollY)
EndProcedure
; Main program
OpenWindow(#winMain, 0, 0, 600, 500, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
Read.s url$
WebGadget(#webGadget, 10, 10, 580, 480, url$)
Delay(4000)
timer = SetTimer_(0, 0, 4000, @Tick()) ; Tick every 4 seconds
Repeat: Until WaitWindowEvent() = #PB_Event_CloseWindow
KillTimer_(0, timer)
End