|
|
|
Home, End, Page Up, Page Down with Text Members
Added on 12/29/2005
|
This behavior script can be attached to a field or text member. It will allow the user to use the Home, End, Page Up, and Page Down keys as they were intended when editing a text/field member.
property spriteNum, pSprite, pMem
on beginSprite me
pSprite = sprite(spriteNum)
pMem = pSprite.member
end
on keyDown me
Case the keyCode of
115: -- Home
aChar = pMem.selection
theLocV = pMem.charPosToLoc(aChar[2] + 1)[2]
theChar = pMem.LocToCharPos(point(0, theLocV)) - 1
pMem.selection = [theChar, theChar]
119: -- End
aChar = pMem.selection
theLoc = pMem.charPosToLoc(aChar[2] + 1)
theChar = pMem.LocToCharPos(point(pMem.width, theLoc[2])) - 1
if pMem.char[theChar] = " " then theChar = theChar - 1
pMem.selection = [theChar, theChar]
116: -- Pg Up
pMem.scrollTop = max(0, pMem.scrollTop - pSprite.height)
121: -- Pg Down
pMem.scrollTop = min(pMem.height - pSprite.height, pMem.scrollTop + pSprite.height)
otherwise
pass
end Case
end
|
|