iOS htmlViewer scroll position

Hello everyone,

Is there a way to find the Scroll position of an htmlViewer in order to hold it, refresh Data in the html and then set the previous position again?
Or another more efficient way?
I have a Xojo iOS App that uses html Viewer to show live results which i refresh every 45 seconds but i want the html to show the scroll position that I am watching.

Thank you in Advance

Hi Sebastian,

Yes it is possible. The HTMLViewer has a scrollView object with a scroll position.

Using Jason King’s iOSKit:

[code]Declare Function scrollview Lib UIKitLib selector “scrollView” (obj_id As ptr) As ptr

Dim scroll as ptr = ScrollView(HTMLViewer1.Handle)

Dim offset As New Foundation.NSPoint

#If Target32Bit
Declare Function ContentOffset_ Lib UIKitLib selector “contentOffset” (obj_id As ptr) As nspoint32
Dim pt As NSPoint32 = ContentOffset_(scroll)
offset.x = pt.x
offset.y = pt.y

#ElseIf Target64Bit
Declare Function ContentOffset_ Lib UIKitLib selector “contentOffset” (obj_id As ptr) As nspoint64
Dim pt As NSPoint64 = ContentOffset_(scroll)
offset.x = pt.x
offset.y = pt.y

offset will then have the X and Y positions of the scroll.

After loading you will need to use the setContentOffset function to reset the position.

Jeremie just so you know you can actually make the assignments for offset to just

offset = pt Or Offset = ContentOffset_(scroll)
Since Operator_Convert in NSPoint handles the assignment for you. I intended iOSKit to never require you to use the 32/64 bit structures directly and instead let the wrapper do everything for you to make it easier to use, but it works either way.

Thank you Jeremie and Jason for the answers.

The only problem is that you need to wait for the html to be loaded in order
to set the scroll position. Do you know if there is a declare to catch load finish event for ioshtmlviewer?
I am currently using a timer that sets scroll 10 mills after i try to load my html.

You’re welcome,

Yes there is, Jason posted a Xojo project to expose the htmlViewer delegate that has events for finished loading.

I’m sorry I don’t have a link for the project file.

I found it. Thank you again Jeremie.