LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
chris9610
- Posts: 79
- Joined: Fri Mar 20, 2009 4:38 pm
Post
by chris9610 » Tue Oct 06, 2009 3:26 pm
I am looking for a solution to this issue. I can limit an input field to a determined length but this also changes a part of the behavior.
Code: Select all
on keydown
if the length of me >= 6 then focus me
else pass keydown
end keydown
This works fine until I use it while editing and existing field contents. When this field contents is full and hilighted then you must press the BACKSPACE KEY or the DELETE KEY to change the contents.
If the field is not full then the behavior is normal and any key will erase the existing contents.
Is there a way to make it behave the same even if the field length is full?
Developing with Windows XP & Revolution 4.5
-
sturgis
- Livecode Opensource Backer

- Posts: 1685
- Joined: Sat Feb 28, 2009 11:49 pm
Post
by sturgis » Tue Oct 06, 2009 6:13 pm
This should work. Check for a selection first, if anything is selected, pass the key, else check length and determine if its at max size, if not pass the key, else focus me.
Code: Select all
on keyDown theKey
if the length of the selectedText of me > 0 then
pass keyDown
else if the length of me >= 6 then
focus me
else
pass keyDown
end if
end keyDown
chris9610 wrote:I am looking for a solution to this issue. I can limit an input field to a determined length but this also changes a part of the behavior.
Code: Select all
on keydown
if the length of me >= 6 then focus me
else pass keydown
end keydown
This works fine until I use it while editing and existing field contents. When this field contents is full and hilighted then you must press the BACKSPACE KEY or the DELETE KEY to change the contents.
If the field is not full then the behavior is normal and any key will erase the existing contents.
Is there a way to make it behave the same even if the field length is full?
-
chris9610
- Posts: 79
- Joined: Fri Mar 20, 2009 4:38 pm
Post
by chris9610 » Tue Oct 06, 2009 6:21 pm
sturgis:
Many thanks, works as expected now.
Some things are so simple when you know what you are doing.
Developing with Windows XP & Revolution 4.5