Is it possible to limit text input in a field based upon its height?
Scott Morrow
scott at elementarysoftware.com
Fri Jul 20 18:01:54 EDT 2007
Hello.
I once used something similar to what Bob suggested. (Though I should
look at Bob's "line" solution to see if it won't work better.) The
following doesn't work perfectly in all cases... but perhaps it will
provide an idea.
-- this goes in the field
on rawKeyUp
FieldLimiter -- don't allow typing past the visible bottom of the
field
pass rawKeyUp
end rawKeyUp
-- this goes somewhere in the message path of the field(s)
on FieldLimiter -- don't allow typing past the bottom of fixed-sized
fields
if (the textheightsum of the target) > (the height of the target +
12) then -- 12 is a "slop" factor
if (word 4 of the selectedChunk) < (the num of chars of the
target) then
-- they are in the middle of the text somewhere so don't
delete characters off the end
-- play the uAlertSound of stack "Hidden"
exit FieldLimiter
end if
-- they are typing at the end of the text chunk... don't let
them insert characters
delete last char of the target
-- play the uAlertSound of stack "Hidden"
repeat 5 times -- 5 is arbitrary
if the textheightsum of the target < (the height of the target
+ 12) then
exit repeat
end if
delete last char of the target
end repeat
set the scroll of the target to 0
end if
end FieldLimiter
-Scott Morrow
Elementary Software
(Now with 20% less chalk dust !)
web http://elementarysoftware.com/
email scott at elementarysoftware.com
-----------------------------------------------------------------
On Jul 20, 2007, at 11:37 AM, Robert Presender wrote:
> Hi,
>
> If the field height is divided by the textHeight, the result is the
> number of lines.
> You can then limit the number of lines.
> See textHeight and keyDown in the docs. Don't know if the spacebar
> can be used with keyDown.
>
> Regards ... Bob
>
>
> on Tue, 10 Jul 2007 15:55:00 -0700 (PDT) haribo
> <ledersitze at netcologne.de> wrote:
>
> Sarah Reichelt-2 wrote:
>>
>> On 9/17/06, William de Smet <wdesmet at wanadoo.nl> wrote:
>>> Hi there,
>>>
>>> I made a field which is 500(width) x 530(height) pixels and now I am
>>> looking for a way to limit the text input in this field based
>>> upon the
>>> height of the field.
>>> I dont want more text than the height of the field.
>>>
>>
>> If you set the autoTab of a field to true, when the user gets to the
>> last line and presses Return or Enter, it will be as if they pressed
>> Tab to go to the next field. They won't be able to enter more lines
>> than are visible.
>>
>> Cheers,
>> Sarah
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
More information about the use-livecode
mailing list