At 10:53 AM -0800 2001/12/06, Trevor Menagh wrote:
>I am working on an app where I want to detect which key is pressed to launch the app
>(if any) so I can launch to a predefined view if that button was pressed.
>This is what I currently have, and it SOMETIMES works and sometimes does not. very
>weird:
>
>if (cmd == sysAppLaunchCmdNormalLaunch)
>{
> UInt32 _keyState = KeyCurrentState();
>
>...<snip>...
>
>later on I check the _keyState variable and handle it. the this is SOMETIMES there is
>a keyDown event when I press a hard key to launch, and sometimes there is not at this
>point.
>
>Does anyone here know how to get this consistantly?
Your code relies on the user holding down the button long enough for KeyCurrentState
to scan it. Since the user may tap the button quickly, causing the button to be
released before your code begins execution, you are not able to reliably detect the
state of the keys.
There's really no easy way to do what you want upon launch without patching traps
and/or interrupt handlers <insert cautious please-don't-do-thats here>. However, once
your app is launched, you have full control over the keys.
Regards,
Jim Schram
Palm Incorporated
Partner Engineering
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/