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!
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?
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.
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.
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?