Best way to check if a Field is a label?

Peter M. Brigham pmbrig at gmail.com
Fri Jul 10 08:59:25 EDT 2015


Still catching up on my list emails, so a little behind again. I use a virtual property "writable" to identify user input fields. It test not just for locktext but also for traversalon and autohilite.

getprop writable
   ----  a virtual field property  ----
   -- writable = true if locktext = false, traversalon = true, autohilite = true
   --     ie, user can enter text
   -- place this handler in a library stack,
   --     where it will be available everywhere
   -- I usually put the following into a mouseup handler in a library script:
   --    if the commandkey is down and the shiftkey is down \
      --             and the target begins with "field" then
   --       set the writable of the target to not the writable of the target
   --    end if
   -- by Peter M. Brigham, pmbrig at gmail.com — freeware
   
   if not (the target begins with "field") then return empty
   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 writable

setprop writable tf
   ----  a virtual field property  ----
   -- writable = true: set locktext = false, traversalon = true, autohilite = true
   --     ie, user can enter text
   -- writable = false: set locktext = true, traversalon = false, autohilite = false
   -- place this handler in a library stack,
   --     where it will be available everywhere
   -- I usually put the following into a mouseup handler in a library script:
   --    if the commandkey is down and the shiftkey is down \
      --             and the target begins with "field" then
   --       set the writable of the target to not the writable of the target
   --    end if
   -- by Peter M. Brigham, pmbrig at gmail.com — freeware
   
   if not (the target begins with "field") then exit writable
   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 writable

-- Peter

Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig


On Jul 8, 2015, at 6:27 AM, Peter W A Wood wrote:

> Thanks, Hugh
> 
> I’m trying to find the best way to clear all the fields in which data can be entered on a card. At the moment I use this code:
> 
> repeat with y = 1 to the number of fields of this card
>    if not the lockText of Field y then
>      put empty into Field y
>    end if
>  end repeat
> 
> It works for my simple program but using a customProperty would be safer.
> 
> Regards
> 
> Peter
> 
> 
>> On 8 Jul 2015, at 18:09, FlexibleLearning.com <admin at FlexibleLearning.com> wrote:
>> 
>> Hi Peter
>> 
>> As you will have gathered, there is no "label" property as such, simply a
>> field with pre-defined attributes including lockText. It depends what you
>> are trying to do and why you need to identify them, but if you need to
>> regularly test the easiest way may be to manually specify a customProperty
>> for each label field so that...
>> 
>> If the cLabelStyle of the target = true then [etc]
>> 
>> Best regards
>> 
>> Hugh Senior
>> FLCo
>> 
>> 
>> 
>>> -----Original Message-----
>>> At the moment I?m checking the lockText property to distinguish a Label
>>> Field. Is there a better or more reliable way?
>>> 
>>> Regards
>>> 
>>> Peter
>> 
>> 
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list