Dispatch-Sending keyDown
Richard Gaskin
ambassador at fourthworld.com
Mon Oct 26 10:35:58 EDT 2009
DunbarX wrote:
> A char typed into a field is actually written via a "keyDown" message
> reaching the engine. It doesn't just appear there via some other mechanism. At
> least that is what I believed. How it gets there is a matter of choice. This
> all seems like what I would consider "normal handling".
>
> So I just wanted to know why I could not send that message explicitly, by
> hand. You can in HC, and I wondered why you could not in Rev. Why would it
> not continue along, like all other messages:
>
> on sendBeep
> send "beep" && 3 to this stack
> end sendBeep
>
> This works fine. What is the thing about keyDown? In other words, what is
> the difference, trying to understand the way things work. If your point is
> that the message is stopped for some reason if I intercept it and send it
> rather than passing it to the engine, then I am really confused.
>
> I am with Richard in thinking it is some sort of bug.
Please review my post:
<http://lists.runrev.com/pipermail/use-revolution/2009-October/129600.html>
I also summarized it here:
<http://lists.runrev.com/pipermail/use-revolution/2009-October/129641.html>
The possible bug I noted was the difference between dispatch and send.
Specifically, you can "dispatch" a message to a stack and it works well,
but if you "send" the same message to the same stack the engine will
complain with an error.
And IMPORTANT POINT apparently missed each of the times I've written it
is that there does not appear to be a bug with "dispatch".
In brief:
- IF you want normal engine handling,
THEN don't do anything and let the engine handle it
- IF you want custom handling up front and then want to the engine
to handle it after,
THEN do your custom processing and then use "pass" to let the
engine handle it
- IF you want to split your custom processing so that half is done
in the control and half is done in the stack,
THEN do what you want in the control and use "dispatch" (or, when
it's fixed, "send") to call the handler in the stack
But please keep this in mind: the engine is not a stack, nor a stack
the engine. I don't know what sort of ambiguity the HC team may have
had for things like this, but in Rev "stack" and "engine" are not
synonymous; rather very different things, and you would only send a
message to a stack if it was indeed the stack that you wanted to handle
it. If instead you want the engine to handle it, just use "pass" and
it'll find it's way to the engine as you would expect and as the many
examples already posted in this thread have shown.
Perhaps HC allowed you to send message to any arbitrary point in the
message path beyond the current script regardless whether or not there's
a handler for it there as a more verbose alternative to "pass". But as
I explained in detail earlier there are reasons why Rev doesn't work the
same way with messages, and instead requires that you use the method
which is simpler and faster in both xtalks, "pass <messageName>".
Learning Rev isn't the hard part. It's unlearning the ambiguousness of
HC that's hard. ;)
--
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