I want to limit a text filed to the first 3 lines
Code: Select all
on keyDown thePressedKey
if the number of lines of me ....
end keyDown
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Code: Select all
on keyDown thePressedKey
if the number of lines of me ....
end keyDown
Code: Select all
on returninfield
if the num of lines of me < 3 then
pass returninfield
end if
end returninfield
on enterinfield
if the num of lines of me < 3 then
pass enterinfield
end if
end enterinfield
Code: Select all
on returninField
if word 2 of the selectedLine of me >=3 then
put line 1 to 3 of me into me
else
pass returninField
end if
end returninField
Code: Select all
on keyDown
if TypingAllowed() then
pass keyDown
end if
end keyDown
on rawKeyUp
if not TypingAllowed() then
repeat until TypingAllowed()
delete last char of me
end repeat
end if
pass rawKeyUp
end rawKeyUp
on returnInField
if TypingAllowed() then pass returnInField
end returnInField
on enterInField
if TypingAllowed() then pass enterInField
end enterInField
-----------------------------------------------------------
function TypingAllowed
if the dontWrap of me then
if the number lines in me < 4 then
return true
end if
else
if the numberOfWrappedLines of me < 4 then
return true
end if
end if
return false
end TypingAllowed
------------------------------------------------------------
getProp numberOfWrappedLines
put the textHeightSum of me into tTextHeightSum
if the fixedLineHeight of me then
put the effective textHeight of me into tLineHeight
else
put the effective textSize of me into tLineHeight
end if
get tTextHeightSum / tLineHeight
return it
end numberOfWrappedLines
yes, we are just lazy!FredBeck wrote:You're all assuming the don'tWrap property of the field is true!
...
Code: Select all
on keydown
put (item 2 of the selectedloc of me + the vscroll of me) div (the effective textheight of me) into tLine
if tLine < 3 then pass keydown
end keydown