Insert text in field
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Insert text in field
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?
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Insert text in field
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
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:
You will get empty.
Now, again in msg:
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.
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
Now, again in msg:
Code: Select all
set the textSize of last field to 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
Hi,
I understand your question this way [explanation in square brackets by me):
If you want your field to keep its text in Calibri 13, give it this code:
Have fun!
I understand your question this way [explanation in square brackets by me):
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
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!
-
- VIP Livecode Opensource Backer
- Posts: 10048
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Insert text in field
See the clipboardData global property in the Dictionary. It's an array, with keys for many representations.
Try:
Try:
Code: Select all
put the clipboardData["text"] into the selection
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Insert text in field
Thank you, this work like a charm. Thanks to everyone else for the help.AxWald wrote: ↑Sun Oct 11, 2020 10:50 pmHi,
I understand your question this way [explanation in square brackets by me):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:Have fun!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
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Insert text in field
Um . . .Answer then is: If you paste styled text into a field, LC will try to keep these attributes.
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.