Avoiding mouse polls

Ken Norris (dialup) pixelbird at interisland.net
Sat Dec 14 23:21:00 EST 2002


> From: Cubist at aol.com
> Date: Sat, 14 Dec 2002 15:47:04 EST
> Subject: re: Avoiding mouse polls

> In MC/Rev, you can do something like this:
> 
> # in card script
> local ListHilite,HiliteNumber,StackState
> # "ListHilite" is a comma-delim. list of the items that get hilited
> # "HiliteNumber" is the number of the list-item that was most recently hilited
> # "StackState" contains a string which lets you control what's going on
> 
> on CycleHilite
> HiliteOff (item HiliteNumber of ListHilite)
> # "HiliteOff" is a separate handler that removes your non-standard
> 'hiliting'
> put 1 + (HiliteNumber mod (the number of items in ListHilite)) into
> HiliteNumber
> HiliteOn (item HiliteNumber of ListHilite)
> # "HiliteOn" is a separate handler that creates your non-standard 'hiliting'
----------
Ohhhh, goodie! I'm such a RR newbie...I was going to suggest maybe some kind
of idle thing. This is the _key_ thing I was looking for in RR, but didn't
know what it was:
********************************************************************
 if StackState = "idle" then send "CycleHilite" to me in 1 second
********************************************************************
Let me look this (StackState) up on the other machine (accessing the RR docs
in this old PB is painfully slow, sometimes causes crashes) tomorrow.
----------
> # "1 second" or however fast you want the hiliting to change from one item
> to another
> # note the use of StackState here
> end CycleHilite
> 
> on mouseUp
> do (item HiliteNumber of
> "ScrollHorizRt,ScrollHorizLf,ScrollVertUp,ScrollVertDn")
> # the items in this list are separate handlers
> # each of these handlers should take care of (re-)setting the value of
> StackState in an appropriate fashion
> end mouseUp
> 
> This way, there's no mouse polling, as the stack waits patiently for the
> user to click. When the user does click, the stack executes whatever handler
> is associated with whatever thingie was hilited at the time; otherwise,
> CycleHilite just chugs quietly along.
-----------
I see. I didn't know about StackState. WunnerfulThing that. Every one kept
telling me things that wouldn't work with a repeat loop, but retrieving
"idle" from StackState is the real key. As it is here, it replaces a similar
thing which would be done with an "on idle" handler in HC. There's a related
thread, "Blink" going on over in the HC group list, which I've been
following. Very similar stuff.

Thanks much,
Ken N.




More information about the Use-livecode mailing list