Keyboard Event

Scott Raney raney at metacard.com
Wed Jul 31 14:26:01 EDT 2002


On Tue, 30 Jul 2002 Simtech Publications <switchedon at hsj.com> wrote:

> > Setting a flag when the key is first depressed is one way to handle this.
> 
> Yes. That's how I had to do it in earlier versions of Director before the
> KeyPressed() function.
> 
> > How about using a different key, Escape for example? Then you can
> > catch it in a rawkeydown handler in the card or stack script.
> 
> I'm converting existing Director programs to Revolution in order to deliver
> them for Mac OS X. The Mac 68k, Mac PPC and Windows versions all use the
> control key. I don't want to risk confusing my customers by using esc for
> the OS X versions.

Your real problem here is a design flaw in all Mac OSs: no keyboard
events are generated when modifier keys are pressed.  On Win32 and
UNIX systems you can easily do this in the proper event-driven manner
using a rawKeyDown handler.

> Here is a repeat loop that allows the user to press the control key to
> interrupt several seconds of music and return directly to the main menu...
> 
> repeat until the sound is done
>   if the controlkey is down then
>     play stop
>     go to cd "main menu"
>   end if
> end repeat
> 
> If that works, I wonder why this doesn't?...
> 
> on idle
>   if the controlkey is down then go to cd "main menu"
> end idle

Unfortunately both of these methods are a bad idea for OS X (the first
is even specficially prohibited by the developer guidelines for that
platform).  Please read the following before you go down this road any
further:

 http://www.hyperactivesw.com/polling.html

Then search the doc and list archives for examples of using "send
.. in" to do a periodic poll.  If it were me, though, I'd just work
around the Mac OS design flaw by accepting any key in a rawKeyDown
handler, not just modifiers.
  Regards,
    Scott

> Cheers... Bill Lynn, Publisher
> Simtech Publications
> http://www.hsj.com

********************************************************
Scott Raney  raney at metacard.com  http://www.metacard.com
MetaCard: You know, there's an easier way to do that...




More information about the Use-livecode mailing list