|Home||Gadgetman||Forum||Book Reviews||Links||Contact me||X-UFO|
|Gadgets||Processors||Programming School||Old news|
we can divide the events into 2 groups:
PROC eventloop: LOCAL eventdata&(16) REM to store the event information.... ~~~~~ ~~~~~ DO GETEVENT32 eventdata&() REM Waits for something to happen, and then store it in the array. IF (eventdata&(1) AND KEvNotKeyMask&) = 0 REM If this is true it was a keypress. handlekey: ELSEIF eventdata&(1) = KEvCommand& REM System command(C/O/X)? handlesystem: ELSEIF eventdata&(1) = KEvPtr& REM Pointer event? handlepointer: ------ ELSIF eventdata&(1) = KKeySidebarMenu% REM not necessary, but REALLY should be used. It detects if the handlemenu: REM user uses the pen to activate the menu. ------ ELSE REM forget about the ones you don't use ENDIF UNTIL a_certain_warm_place_freeze_overSimple, eh...
To recap: Use a 16 element LONG INTEGER(&) array to store the information from GETEVENT32
Use DO UNTIL. Do not use testevent unless you want to empty your batteries.(it's useful in games and other 'realtime' apps, and of course in processor intensive parts of your app to test for a cancel... :-)
Use IF ELSEIF ...ENDIF to find out what kind of event occured, and to run the correct PROC.
Be careful to handle ALL relevant events.(The Focus events 'lostfocus', 'gainedfocus' isn't that important to a word processor, but should be considered in f.example Games, so that the game is paused when in background.
The KKeySidebarMenu% event REALLY should be tested for. It signals that the user pointed the stylus at the menu symbol at the upper left corner of the screen. It should be handled the same way you would handle the [Menu] Button. Not doing this can ruin the look and feel of the program, and cause the user to dump it! (I personally don't register pen avare Apps that don't use this )
BTW: Keep this PROC as short as possible...
Doing more testing than absolutely necessary to select the correct PROC to call will just result in an app that is slower to respond to ALL other events...
|<<5. Setting up the Data>>|
|<<7. Handling the [Menu] key>>|