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
-
jmburnod
- VIP Livecode Opensource Backer

- Posts: 2729
- Joined: Sat Dec 22, 2007 5:35 pm
-
Contact:
Post
by jmburnod » Wed Jan 05, 2011 12:38 pm
Hi All,
This script limit the num of chars in a fld when the user paste a text in the field
Meaby you have a more simple way
Code: Select all
on commandKeyDown pKey
if pKey is "V" then
put the clipboardData["text"] into MonCB
put the length of MonCB into NbCCB
put the selectedchunk into bufCC
put the value of word 2 of bufCC into depC
put the value of word 4 of bufCC into FinC
put last word of bufCC into LeFld
if depC > FinC then
put the length of fld LeFld into NbCfld
else
put FinC-depC+1 into NbCfld
end if
put NbCCB+NbCfld into NbCharsTot
put NbCharsTot
if NbCharsTot > 10 then
beep
else
pass commandKeyDown
end if
else
pass commandKeyDown
end if
end commandKeyDown
Best
Jean-Marc
https://alternatic.ch
-
Mark
- Livecode Opensource Backer

- Posts: 5150
- Joined: Thu Feb 23, 2006 9:24 pm
-
Contact:
Post
by Mark » Mon Jan 10, 2011 1:26 am
Hi Jean-=Marc,
The following approach seems easier to me.
Code: Select all
on commandKeyDown theKey
put 1000 into myLimit
if theKey is "V" then
put char 1 to (myLimit - number of chars of the text of me) of \
the clipboardData["text"] into the selection
else pass commandKeyDown
end commandKeyDown
I didn't test this script.
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
jmburnod
- VIP Livecode Opensource Backer

- Posts: 2729
- Joined: Sat Dec 22, 2007 5:35 pm
-
Contact:
Post
by jmburnod » Mon Jan 10, 2011 9:28 am
Hi Mark,
Yes, it work if the script is in fld script
Thank
Jean-Marc
https://alternatic.ch