When has a field changed?
Mark Schonewille
m.schonewille at economy-x-talk.com
Tue Oct 25 19:33:04 EDT 2011
James,
// this is a field script, providing
// a safe way to check if a field has changed
local lHash
local lHasChanged
on openField
put md5Digest(the text of me) into lHash
pass openField
end openField
on closeField
checkHash
pass closeField
end closeField
// depending on the purpose of your field
// you may or may not want to include ths handler
on exitField
checkHash
pass exitField
end exitField
// alter this handler as needed
private command checkHash
put md5Digest(the text of me) into myHash
put (myHash is not lHash) into lHasChanged
if lHasChanged then
send "mouseUp" to btn ProcessChanges
end if
end checkHash
getProp changed theCurret
if theCurrent is true then
return (md5Digest(the text of me)) is lHash
else
return (lHasChanged is true)
end if
end changed
--
Best regards,
Mark Schonewille
Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553
Become our partner in sales http://qery.us/16r Start selling Color Converter today. 20% commission!
On 25 okt 2011, at 23:21, James Hurley wrote:
> I have a text field (unlocked) that the user can edit, but I want to know when and to deal with the changes.
>
> Here is what I have come up with, something of a kludge. Is there a cleaner way?
>
> on mouseEnter --Enter the field
> set the textChange of me to false
> end mouseEnter
>
> on rawkeydown tKey
> if the textChange of me is true then
> pass rawKeyDown
> else
> set the textChange of me to true
> pass rawKeyDown
> end if
> end rawKeyDown
>
> on mouseLeave
> if the textChange of me is false then
> exit mouseLeave
> else
> send "mouseUP" to button "ProcessChanges" --This is where the change is dealt with.
> end if
> end mouseLeave
>
>
> Jim Hurley
More information about the use-livecode
mailing list