Scroling a field while user types?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
EssoAir
Posts: 52
Joined: Thu Feb 20, 2014 7:53 pm

Scroling a field while user types?

Post by EssoAir » Sun Nov 16, 2014 6:45 am

Hey,

I was writing this simple game and ran into a problem that I understand, but don't know how to solve in LiveCode.

Heres the script: https://dl.dropboxusercontent.com/u/122 ... e.livecode

The part I'd like to highlight is this:

Code: Select all

on scrollMe
   if stillScrolling = 1 then
      set the scroll of me to the scroll of me + 1
      wait 1 millisecond
      scrollMe
   end if
end scrollMe
Why is it that this causes the whole program to be useless until it inevitably throws an error (due to scrolling past the actual limit of the scrollable area)

I'm not asking about error handling. I'm saying Id like people to be able to type into the bottom field while the top one is being automatically scrolled. How can this be done?

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Scroling a field while user types?

Post by Simon » Sun Nov 16, 2014 7:10 am

Hi EssoAir,
Well you actually almost had it right... the right idea but try this
send "scrollMe" to me in 1 millisec
the wait you have blocks all.

Now that 1 millisec is waaayyyyyy too short, and is the reason for that recursion error, not the end of the scrolling fld. The screen hasn't finished updating before it gets about a billion more scrollme's.
You are going to have to play with the +1 px and the time to get what you want.

And I have the fix for getting you out of your scroll loop :)

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

EssoAir
Posts: 52
Joined: Thu Feb 20, 2014 7:53 pm

Re: Scroling a field while user types?

Post by EssoAir » Sun Nov 16, 2014 8:23 am

Simon wrote:Hi EssoAir,
Well you actually almost had it right... the right idea but try this
send "scrollMe" to me in 1 millisec
the wait you have blocks all.

Now that 1 millisec is waaayyyyyy too short, and is the reason for that recursion error, not the end of the scrolling fld. The screen hasn't finished updating before it gets about a billion more scrollme's.
You are going to have to play with the +1 px and the time to get what you want.

And I have the fix for getting you out of your scroll loop :)

Simon
But the error isn't the problem. The problem is the act itself blocks any other interaction with the application. How can I have both things run simultaneously?

EDIT: Ok nm I did the fix and it works. LiveCode is very strange. I come from such a Javascript mindset that this stuff doesn't click with me as easy.

Thank you!

Post Reply

Return to “Talking LiveCode”