Page 1 of 1

Insert text in field

Posted: Sun Oct 11, 2020 3:24 pm
by SEAL29
If i paste text (cmd+v) in field, it always converts it to the font used by that program. In the Inspector under the Font option i setting the font is Calibri and size is 13. How that should be set so that it does not change?

Re: Insert text in field

Posted: Sun Oct 11, 2020 9:14 pm
by richmond62

Code: Select all

set the textFont of field "fDATA" to "Courier"
set the textSize of field "fDATA" to 36

Frankly, you'd save a lot of time, instead of asking basic questions here by just poking around in the Dictionary.

Re: Insert text in field

Posted: Sun Oct 11, 2020 9:35 pm
by dunbarx
Ask anything you want. We love to answer.

A new field will inherit the text properties of the OS unless you explicitly set them yourself. Such properties are, by default, empty.

Try it. Make a new field and from msg:

Code: Select all

answer the textSize of last field
You will get empty.

Now, again in msg:

Code: Select all

set the textSize of last field to 14
If you now ask for the textSize of that same field, you will get 14.

Lots of properties work this way. This can cause a lot of wasted effort if you forget this.
Craig.

Re: Insert text in field

Posted: Sun Oct 11, 2020 10:50 pm
by AxWald
Hi,
I understand your question this way [explanation in square brackets by me):
SEAL29 wrote:
Sun Oct 11, 2020 3:24 pm
If i paste text [from Word] in field, it [LiveCode] always converts it to the font used by that program [Word].
[...] How that should be set so that it does not change?
Answer then is: If you paste styled text into a field, LC will try to keep these attributes.

If you want your field to keep its text in Calibri 13, give it this code:

Code: Select all

on textchanged
   set the textFont of char 1 to -1 of me to "Calibri"
   set the textSize of char 1 to -1 of me to 13
   --  you need to set the styles, too:
   set the textStyle of char 1 to -1 of me to "plain"
end textchanged
Have fun!

Re: Insert text in field

Posted: Mon Oct 12, 2020 5:06 am
by FourthWorld
See the clipboardData global property in the Dictionary. It's an array, with keys for many representations.

Try:

Code: Select all

put the clipboardData["text"] into the selection 

Re: Insert text in field

Posted: Mon Oct 12, 2020 3:03 pm
by SEAL29
AxWald wrote:
Sun Oct 11, 2020 10:50 pm
Hi,
I understand your question this way [explanation in square brackets by me):
SEAL29 wrote:
Sun Oct 11, 2020 3:24 pm
If i paste text [from Word] in field, it [LiveCode] always converts it to the font used by that program [Word].
[...] How that should be set so that it does not change?
Answer then is: If you paste styled text into a field, LC will try to keep these attributes.

If you want your field to keep its text in Calibri 13, give it this code:

Code: Select all

on textchanged
   set the textFont of char 1 to -1 of me to "Calibri"
   set the textSize of char 1 to -1 of me to 13
   --  you need to set the styles, too:
   set the textStyle of char 1 to -1 of me to "plain"
end textchanged
Have fun!
Thank you, this work like a charm. Thanks to everyone else for the help.

Re: Insert text in field

Posted: Mon Oct 12, 2020 4:18 pm
by richmond62
Answer then is: If you paste styled text into a field, LC will try to keep these attributes.
Um . . .

Be aware that that will only hold true so long as that font exists on an end-user's operating system . . .

&&&&&&

cross-platform fonts are a minefield of horros.