A gripe about the dictionary (battery life)

Geoff Canyon gcanyon at gmail.com
Fri Jan 3 15:39:05 EST 2014


I've long been annoyed that LC seems to hover at about 6% CPU use, even
when in the background. I finally did some investigation, and found out
something I didn't know: holding down the option (alt) key underlines all
the links in the dictionary. To accomplish this, the dictionary uses this
code:

*on* checkForAltKey

   *if* altKey() is "up" and sAltKeyDown is not false  *then*

      *## Alt key has been released*

      *put* false into sAltKeyDown

      entryHideLinks

   *else* *if* altKey() is "down" and sAltKeyDown is not true *then*

      *## Alt key has been pressed*

      *put* true into sAltKeyDown

      entryDisplayLinks

   *end* *if*

   *send* "checkForAltKey" to me in 250 milliseconds

*end* checkForAltKey


That's in the script of stack "revDictionary" One way to fix it would be to
just empty the script to remove the feature.


Instead, I made two changes. First, I increased the delay to a second. That
reduces the CPU to about 2% when the dictionary is in front. Then I added
suspend and resume handlers, so the altKey script runs only when the
dictionary is in front. When I'm working with a stack or editing a script
with the dictionary in the background, load in the dev environment can fall
to 0%.


Here's the resulting script. This is the dev environment, so standard
disclaimers apply. Be sure to save the dictionary once you make the change.


*on* checkForAltKey

   *if* altKey() is "up" and sAltKeyDown is not false  *then*

      *## Alt key has been released*

      *put* false into sAltKeyDown

      entryHideLinks

   *else* *if* altKey() is "down" and sAltKeyDown is not true *then*

      *## Alt key has been pressed*

      *put* true into sAltKeyDown

      entryDisplayLinks

   *end* *if*

   *send* "checkForAltKey" to me in 1 second

*end* checkForAltKey


*on* suspendStack

   stopAltKeyCheck

*end* suspendStack


*on* resumeStack

   startAltKeyCheck

*end* resumeStack



More information about the use-livecode mailing list