Text Properties of Newly Created Fields

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10356
Joined: Wed May 06, 2009 2:28 pm

Text Properties of Newly Created Fields

Post by dunbarx » Mon Oct 28, 2013 1:14 am

Two questions:

1- In a new session, make a field. The textSize and textHeight of that field are empty. I always thought that the default "textHeight" was, as the dictionary says, 4/3 times the textSize. But if I set the textSize of that newly created field, the textHeight is still empty. Is the textHeight not automatically set when the textSize is? If I set the textSize in a button script:

Code: Select all

on mouseUp
   create field
   set the textSize of the last field to 12
   answer the textSize of the last field && the textHeight of the last field
end mouseUp
Same if you set the textSize of a field by hand, and ask for the textHeight.

2- The templateField seems not to be a global "object", but rather local to the script that creates a new field. In other words, one cannot set the properties of the templateField outside of a handler (or manual action) that creates a new field. In still other words, one cannot set a property there and then assume that a new field dragged from the tools menu will inherit those properties. In a button:

Code: Select all

on mouseUp
   set the textSize of the templateField to 12
   create field
   answer the textSize of the last field -- gives 12
end mouseUp
But you will get empty if you drag another field from the tools menu, and ask for the textSize of that last field

The whole point of such an entity is to sit in the background, sort of like a global property set, providing a framework for new fields. I think I have used it this way in the past and thought it was a very cool feature. It has very limited usefulness this way. I am depressed. What am I missing?

Craig Newman

Klaus
Posts: 14212
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Text Properties of Newly Created Fields

Post by Klaus » Mon Oct 28, 2013 1:49 pm

HI Craig,

1. try to get "the effective textheight" etc.
Newly created object inherit this from its group -> card -> stack -> HOME-stack.

2. I think LC does its own "init" stuff with the templateXXX when you drag an new object from the LC palette,
which will override your previously made setting.


Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10356
Joined: Wed May 06, 2009 2:28 pm

Re: Text Properties of Newly Created Fields

Post by dunbarx » Mon Oct 28, 2013 3:13 pm

Klaus.

I know about the effective textSize. The local property, likely inherited from the card for each new field, which is its owner, is why it is empty.

My real question is about the nature of the templateField (or templateAnything). Is it true that this can only be used as a template within a single handler, that it is not a "global" virtual object, from which the properties of newly created eponymous objects are based? I am trying to find where I thought I once used this in just that way. That I set certain properties of a templateXXX by hand as if I had set a custom property of an object or set a global variable, and then could rely on those properties being inherited at any subsequent time by any newly created object.

I have this wrong, I assume? I suspect, though, that I am missing the correct way to use them. And if I am not, LC sorely needs them to work they way I thought they did.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10356
Joined: Wed May 06, 2009 2:28 pm

Re: Text Properties of Newly Created Fields

Post by dunbarx » Mon Oct 28, 2013 6:57 pm

Klaus.
I think LC does its own "init" stuff with the templateXXX when you drag an new object from the LC palette,
which will override your previously made setting.
OK. I will have to remember that, though I will post a user note in the dictionary.

The templateXXX is in fact a global virtual object, but only for those objects created under script control. It does not work with objects drawn from the tools palette. And maybe this is not so crazy. Since the tools palette contains many styles of button and field objects. it makes a certain amount of sense that if the style of the templateButton was "checkBox", say, then if you dragged a radio button, you may not want it to suddenly transmogrify into a checkbox.

Craig

Post Reply