Sending keyDown

Richard Gaskin ambassador at fourthworld.com
Mon Oct 26 12:48:44 EDT 2009


DunbarX wrote:
> My original intent was to have the char written into the field, and then do 
> stuff with the new text in the very same handler. The "send" command was at 
> the very beginning. I could not "pass" keyDown as that terminates the 
> handler. I had found several workarounds, and helpful others suggested even 
> better ones.

One man's workaround is another's solution. :)

If you don't have a keyDown handler in the stack, sending it that 
message by any means, whether "send" or "dispatch", isn't the solution 
because there's nothing there to handle it.

If you want to put the incoming character after the field's text, you can:

   put k after me

...and then proceed to do anything you like with it.

But the simplest with-the-grain solution may be Sarah's, where she 
suggested using keyUp instead, a message I don't think HC offered.

With keyUp the character has already been put into the field, so you can 
act on it without any additional processing to put it there.  Let the 
engine do the work where it can:

Know the engine.
Trust the engine.
Use the engine.

:)

By taking advantage of the 40% or more new message Rev offers that HC 
didn't, you'll discover a great many ways so solve problems that would 
have required steps that might have seemed logical enough in HC but 
which are arguably kinda odd (like sending messages to scripts with no 
handler for them).  If it seemed "intuitive" at one time that's only 
because of habit after having learned it, not because much in any 
programming language is literally intuitive.  Computers are no more 
intuitive than cars, which require months of learning to use safely.

The "unlearning curve" is sometimes steeper in Rev than its learning 
curve, but thankfully the See Also entries in the Dictionary make 
explorations there a valuable habit.

For example, I've been working with the engine since '97, but only 
recently discovered the tempName function, having previous used my own 
custom functions to make temp files.

This is a rich, deep jungle we're in, and like all jungles our old 
compasses are rarely useful there, requiring us instead to pay closer 
attention to the rivers and mountains, and keep our map (the Dictionary) 
at our side.  But like all jungles there's a rich abundance of life to 
be found, and with a handful of skills you can live off the land in high 
style, lending a whole new meaning to "going native". :)

--
  Richard Gaskin
  Fourth World
  Rev training and consulting: http://www.fourthworld.com
  Webzine for Rev developers: http://www.revjournal.com
  revJournal blog: http://revjournal.com/blog.irv



More information about the use-livecode mailing list