Handling Key Messages
Dar Scott
dsc at swcp.com
Fri Jul 28 12:45:36 EDT 2006
On Jul 28, 2006, at 6:52 AM, Gregory Lypny wrote:
> (On a related issue, why is it that I get an error [can't find the
> handler] when I try to send an EnterInField or similar message to a
> field?)
First possibility: A 'send' without the 'in' time clause is assumed
to require that a handler is in the path. A 'send' with that clause
is queued into pending messages and dropped into the message path
some time later. That will not generate the error. So, if there is
a potential that the handler has not been defined in a script in the
path from the field down, use send in time.
Second possibility: I have sent messages to objects that were the
same name as GUI event generated messages expecting the engine at the
end of the message path to process it. After all, I can define a
handler for an event message and then pass it--what is the ultimate
that does the work, but just beyond the end of the message path? I
have concluded that I am mistaken. For example I can't do this and
get an "a" inserted into the field:
get "a"
send "keyDown it" to field "field"
So the behavior of a GUI event is not exactly the same as a send with
a built-in handler at the end of the message path. Maybe it is like
a send wrapped in a try/catch where the error is checked for "can't
find handler" and the default is done then. It is probably more
efficient than that.
(Thanks for reminding me. This might be the solution to a problem I
have in emulating controls.)
>
> on rawKeyUp theKey
> if theKey is among the items of (65293,65289,65421) or \
> theKey is an integer
> then
> updateCalculation
> end if
> end rawKeyUp
All key codes will match 'is an integer'. So you are updating for
every key.
Are you looking for digits? The key code for a digit is the ASCII
code for a digit. So you want to check for the range 48 through 57
inclusive.
Dar Scott
More information about the use-livecode
mailing list