"writable" virtual property
Peter Brigham
pmbrig at gmail.com
Sun Nov 11 09:56:30 EST 2007
It occurred to me after mostly lurking on this list for a long time
(and learning a lot) that this little trick might be useful for
someone. In my various personal stacks I often want to lock and
unlock fields for editing vs accepting mousedown events. In the old
HC days, just locking & unlocking the field would do it, but Rev has
unbundled the various aspects of the HC locked field property into
lockText, traversalOn, and autoHilite. So locking a field, making
sure it doesn't accept the focus, and not allowing any selections in
it is now a 3-step process. Solution (in the main stack script):
setprop writable tf -- tf = true | false
if "field" is not in the target then exit writable
try
set the locktext of the target to not tf
set the traversalon of the target to tf
set the autohilite of the target to tf
end try
end writable
getprop writable
if "field" is not in the target then return ""
try
put the locktext of the target into L
put the traversalon of the target into T
put the autohilite of the target into A
if T and A and not L then return true
return false
end try
end writable
call these with things like:
set the writable of fld "y" to true; select after text of fld "y"
if not the writable of me then set the cursor to hand
Saves me a lot of time.
-- Peter
Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig/
"I took a course in speed waiting. Now I can wait an hour in only
ten minutes."
-- Steven Wright
More information about the use-livecode
mailing list