B4J Question textarea ScrollTopPosition behaving strange

sorex

Expert
Licensed User
Longtime User
Hello,

I have a few textarea views where I want to save the current scroll position of.

I'm using a map together with file.writemap & file.readmap to read it back in.

Doing so I noticed the following issues...

1. restoring the position after setting the text doesn't work at all.

2. using callSubDelayed to a sub where it sets the position makes the text jump a few pixels only

3. using a 1 second timer to restore the position works fine.

4. using a sleep(100) after setting the text also seems to be a way to bypass the problem.


Does this mean that the textarea.text is running async?

And is there a way to use wait for for this as the sleep method is a gamble as one would pick the lowest working value that might bug again on a slower machine?
 

sorex

Expert
Licensed User
Longtime User
another method that works...

setting the text
request focus
use the hasfocus event to set the scroll position.

on the text areas where the text is static setting the scrollposition works without any problems.

Edit:

also using the _TextChanged event fails unless I add a sleep(100) inthere.
 
Last edited:
Upvote 0

sorex

Expert
Licensed User
Longtime User
I'm using code like this...

B4X:
If mSourceSettings.ContainsKey("sourcePos") Then taSource.ScrollTopPosition=mSourceSettings.Get("sourcePos")

it seems that the UI need to update before it works right.

I'm using a sleep(100) right before the code then it works fine.
 
Upvote 0
Top