Detect scroll activity (when LC is not frontmost)

Quentin Long cubist at aol.com
Fri Dec 23 14:37:36 EST 2016


sez dunbarx:
> The "rawkeyDown" message may be trapped as follows:
> 
> on rawkeydown tkey
>    if  tkey = 65308 then doScrollDownStuff
>    else doScrollUpStuff 
> end rawkeydown
Hold it. That code, as written, will trap *A*L*L* rawKeyDown events, and silently kill everything that's *not* a scrollwheel-down event. Which, in turn, means that text input is toast, among other probably-unwanted side-effects. Try something like this instead:

on rawKeyDown DerKey
  switch DerKey
    case 65308
      DoScrollDownStuff
      break
    case 65309
      DoScrollUpStuff
      break
    default
     pass rawKeyDown
  end switch
end rawKeyDown

Note that with the switch structure I've used here, there are a number of perhaps-useful tricks you can pull… but said tricks are strictly outside the scope of the original "how do I detect scrollwheel activity?" problem, so I will leave said tricks as exercises for the reader.
   
"Bewitched" + "Charlie's Angels" - Charlie = "At Arm's Length"
    
Read the webcomic at [ http://www.atarmslength.net ]!
    
If you like "At Arm's Length", support it at [ http://www.patreon.com/DarkwingDude ].




More information about the use-livecode mailing list