Problems Changing Text Size in Field if Pasted From Another App.

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
donbeck@donbeck.org
Posts: 7
Joined: Tue Mar 09, 2021 6:37 pm
Location: Massachusetts

Problems Changing Text Size in Field if Pasted From Another App.

Post by donbeck@donbeck.org » Sat Apr 10, 2021 8:35 pm

I have a field that I keep notes in. I have two buttons that are used to increase and decrease the size of the font in the field. These work fine for the entire field and any text I type into the field. My problem is if I paste text into the field from another app, even though it is completely editable in my field, the size of the text doesn’t change with the buttons I have.

With some of the originally typed text in the field and some pasted text, the text typed into the field changes, but the additional text pasted from a different app stays the same. This occurs whether or not some or all of the text is selected.

What can I do to control the size of all of the text in my field?

andresdt
Posts: 146
Joined: Fri Aug 16, 2019 7:51 pm

Re: Problems Changing Text Size in Field if Pasted From Another App.

Post by andresdt » Sat Apr 10, 2021 9:13 pm

That has happened to me and the solution I found is:

Code: Select all

set the text of field "myField" to the text of field "myField"
that solves it for me.

donbeck@donbeck.org
Posts: 7
Joined: Tue Mar 09, 2021 6:37 pm
Location: Massachusetts

Re: Problems Changing Text Size in Field if Pasted From Another App.

Post by donbeck@donbeck.org » Sun Apr 11, 2021 3:49 am

Thank you andresdt. That solved it. How did you ever come up with that?

andresdt
Posts: 146
Joined: Fri Aug 16, 2019 7:51 pm

Re: Problems Changing Text Size in Field if Pasted From Another App.

Post by andresdt » Sun Apr 11, 2021 3:17 pm

donbeck@donbeck.org wrote:
Sun Apr 11, 2021 3:49 am
Thank you andresdt. That solved it. How did you ever come up with that?
I don't remember when or how it was, I just know that it has helped me countless times. :D :D :D

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Problems Changing Text Size in Field if Pasted From Another App.

Post by jacque » Sun Apr 11, 2021 4:47 pm

I do the same thing sometimes. LC allows you to set text properties on characters in the field and also on the field itself. Character properties override field properties. If the text itself has no properties assigned (size, style, color, etc.) then it inherits the properties of the field.

Pasting text preserves the properties of the text from the original app. You could have changed the size by selecting all the text manually and setting the text size. But it's easier to just remove all the character properties by putting the text into the field from a variable. Text in a variable has no properties, it's just a plain string, so it will inherit the field's text size.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

andresdt
Posts: 146
Joined: Fri Aug 16, 2019 7:51 pm

Re: Problems Changing Text Size in Field if Pasted From Another App.

Post by andresdt » Sun Apr 11, 2021 5:58 pm

@Jacque's post gave me an idea to make a behavior for the fields, which we don't need to keep the format of the original application.

Put the following code in a behavior and set this behavior in your fields.

Code: Select all

on rawKeyDown pKeyCode
    set the clipboardData["text"] to the clipboardData["text"] 
    pass rawKeyDown
end rawKeyDown
What is done is that instead of cleaning the format of the field, the format of the clipboard is cleaned.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”