KeyUp Head Scratcher
Posted: Sat Aug 07, 2010 4:29 pm
I have not been able to resolve a strange dilemma. I'm trying to handle keyUp to perform a task of increase/decrease graphic size. When the "i" key is pressed the graphic increases in size, "d" key = decrease. This works fine, but for some reason after pressing i or d keys, the subsequent pressing of any special keys (enter, shift, alt, numlock, arrows, capslock) seems to trigger the increase/decrease handle. I'm guessing there's just something simple I'm not understanding about the message path or keyUp. What's weird is that if I press the TAB key after pressing I or D key it seems to release the message handle. See attached stack. To duplicate,
1) press i or d key
2) then press any special key and the handle icreaseObjSize or DecreaseObjSize handle will fire.
3) press tab and special keys no longer trigger the the handle until I or D is pressed again.
1) press i or d key
2) then press any special key and the handle icreaseObjSize or DecreaseObjSize handle will fire.
3) press tab and special keys no longer trigger the the handle until I or D is pressed again.
Code: Select all
on keyUP tKey
if tKey is "i" then
increaseObjSize
end if
if tKey is "d" then
DecreaseObjSize
End if
end keyUP
on increaseObjSize
put the height of graphic theObject into tempH
put the width of graphic theObject into tempW
if tempH >400 or tempW >400 then exit increaseObjSize
set the height of graphic theObject to tempH +2
set the width of graphic theObject to tempW +2
end increaseObjSize
on DecreaseObjSize
put the height of graphic theObject into tempH
put the width of graphic theObject into tempW
if tempH <11 or tempW <8 then exit decreaseObjSize
set the height of graphic theObject to tempH -2
set the width of graphic theObject to tempW -2
end DecreaseObjSize