use-livecode Digest, Vol 159, Issue 30
hh
hh at hyperhh.de
Sat Dec 24 10:31:37 EST 2016
Quentin L. wrote:
> Did you read the sample code dunbarx posted? And if you read it, did you
> understand it?
-- Here's the code we both have to understand:
on rawkeydown tkey
if tkey = 65308 then doScrollDownStuff
else doScrollUpStuff
end rawkeydown
The wording of your first post was as if Craig had make a silly beginner's
mistake with that. But it is you who made a mistake by concluding from the
naming of a handler to it's content:
Quentin L. wrote:
> "Hold it. That code, as written, will trap *A*L*L* rawKeyDown
> events, and silently kill everything that's *not* a scrollwheel-down
> event. Which, in turn, means that text input is toast, among other
> probably-unwanted side-effects."
That's logically totally wrong. If you are insulted by one of the words
"totally" or "logically" then I don't insist on that, strike out these
two words and I apologize. But it's still wrong.
Let me explain. Make a new stack with two fields (for output).
###### card's script
-- the code we both have to understand:
on rawkeydown tkey
if tkey = 65308 then doScrollDownStuff
else doScrollUpStuff
end rawkeydown
-- the code that shows your conclusion that the above code
-- "kills everything that is not scrollwheel-down event"
-- is wrong. You can type and 'blindtype' the example range into
-- fld 1 [doesn't respect non-english keymappings, but works].
on doScrollUpStuff
put the keysdown into k; put item 1 of k into k0
if 31 < k0 and k0 < 128 then -- handle an example range
if 65505 is among the items of k then
put upper(numTochar(k0)) after fld 1
else put numTochar(k0) after fld 1
else put "<"&k&">" after fld 1
call "rawkeydown k" of this stack
end doScrollUpStuff
-- we have to use a workaround because our scrollup is broken.
-- click for example the wheel button (if any) and scroll down
-- to get a scroll up (65309)
on DoScrollDownStuff
if mouse(2) is down then -- just as an example
call "rawkeydown 65309" of this stack
else call "rawkeydown 65308" of this stack
end DoScrollDownStuff
###### stack's script
on rawkeydown t
put t into fld 2
-- pass rawkeydown
end rawkeydown
Of course your switch code (= essentially the dictionary example)
is the script one should "usually" use. But that does not mean
that other script's as the first one above are wrong. So, your
conclusion is wrong. That's what I meant.
Don't mind. We all make mistakes. And what's wrong that's wrong.
No matter who wrote it, you or me ;-)
More information about the use-livecode
mailing list