Subject: Re: On KeyDown Bug
Alex Tweedly
alex at tweedly.net
Mon Mar 27 12:30:08 EST 2006
Robert Sneidar wrote:
> I think you missed the point. I DO want the case statement to
> progress without breaks because I want the variable theModifier to be
> ALL of the modifier keys that are being pressed on keyDown. As I
> understand it, case statements without breaks will do that.
No, they won't. Without a break statement, the following code *will be
executed* - i.e. *without* testing the subsequent condition.
e.g.
> put 1 into v
> switch
> case v=1
> put 1 after k
> case v=2
> put 2 after k
> end switch
> put k
will output "12". The first condition is tested, and it passes that test
- so the "1" is put into K. Then the code falls through (without testing
whether or not "v=2" and the second code fragment is executed - so the
"2" is put after K
> And it still doesn't explain how I can end up with a Ctrl in
> theModifier when only the shift key was being held down.
>
Yes it does :-)
> If anyone would please feel free to paste my snippet (previously
> posted) into a stack and observe what happens, I'd be curious if it
> were just me. I am after all going through a KVM switch and a USB hub.
>
I no longer have your snippet of code - but if I correctly understand
what you want, you could do something like
if the optionKey is down then
put "Opt " after theModifier
end if
if the CommandKey is down then
put "Cmd " after theModifier
end if
if the shiftKey is down then
put "Shft " after theModifier
end if
if the controlKey is down then
put "Ctrl " after theModifier
end if
etc.
If you want to test each condition, it's easier to use 'if's than a
'switch'.
--
Alex Tweedly http://www.tweedly.net
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.3.2/293 - Release Date: 26/03/2006
More information about the use-livecode
mailing list