B4J Question textarea ScrollTopPosition behaving strange

Discussion in 'B4J Questions' started by sorex, Apr 15, 2019.

  1. sorex

    sorex Expert Licensed 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?
     
  2. sorex

    sorex Expert Licensed 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: Apr 15, 2019
  3. Erel

    Erel Administrator Staff Member Licensed User

    How are you setting the scroll position? Can you read it? If so then create a small loop with Sleep that updates the position until it is set.
     
  4. sorex

    sorex Expert Licensed User

    I'm using code like this...

    Code:
    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.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice