Home Gadgetman Forum Book Reviews Links Contact me X-UFO
Gadgets Processors Programming School Old news
The [Ctrl] key is used for shortcuts. It's supposed to use the Ctrl combinations visible in the 'pull down Menu'.
Here's how to handle it:

The Eventdata&(16) array contains the key in pos 1, and modifiers in pos 4.

The Keykode is 1 for A, 2 for B....

GLOBAL LCaseKeys$(27)   
GLOBAL UCaseKeys$(27)
------
   LCaseKeys$="noexcv"      REM Place in first PROC
   UCaseKeys$="ah"
-------
   IF eventdata&(4) AND 2 Test for [Shift]
      IF (Eventdata&(1)+64) AND (LOC(UCaseKeys$,CHR$(Eventdata&(1)+64))<>0)
         @("ucase"+CHR$(Eventdata&(1)+64)):
      ELSE
               REM Only gets here if Illegal [Shift]+Key
      ENDIF
   ELSE
      IF (Eventdata&(1)+64) AND (LOC(LCaseKeys$,CHR$(Eventdata&(1)+64))<>0)
         @("lcase"+CHR$(Eventdata&(1)+64)):
      ELSE
               REM Only gets here if Illegal 'Non-Shifted' Key
      ENDIF
   ENDIF

The mess with the LOC command is to ensure that the proc you are about to call is valid.(If it's letter is in the strings it's considered valid.) If you must disable something, just remove it from the string. The strings will also show you which keys are not already used :-) NOT using the strings WILL cause a crash when a user presses an illegal key...

As you can see we can't access ANY of the choices witch had a numeric code in the MENU. Therefore NEVER use numerics(1 - 32) for often used functions!


<<7. Handling the [Menu] key>>
<<How to build an application>>
<<9. System Events>>