How to insert text into a label

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

CAsba
Posts: 432
Joined: Fri Sep 30, 2022 12:11 pm

How to insert text into a label

Post by CAsba » Wed Oct 05, 2022 11:10 am

Hi everyone,
It's me, the embarassing newbie again. I don't seem able to figure out how to write text into a label; size, color, position, all OK, but 'value', that is, the actual text, I can't find how to.

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

Re: How to insert text into a label

Post by Klaus » Wed Oct 05, 2022 11:30 am

Hi CAsba,

well, you already mentioned it and most of the time that is the correct term to use in scripting:

Code: Select all

...
set the label of btn "your_btn_here" to "I'm the label, Sir!"
...
Best

Klaus

CAsba
Posts: 432
Joined: Fri Sep 30, 2022 12:11 pm

Re: How to insert text into a label

Post by CAsba » Wed Oct 05, 2022 11:38 am

Sorry, I don't get it. How ? To be clear, I'm not wanting to write script, or code, into the object, I just want to display a word onto the page (onto the card ?) and I thought, probably mistakenly. that I should use a label to display text. I'm obviously missing something that's probably quite basic.

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

Re: How to insert text into a label

Post by Klaus » Wed Oct 05, 2022 11:40 am

Hm, I don't get it, what object do you want to set the label for?
A button? A group?
Or just a text field without borders?
Or even the titlebar of your stack/window?

CAsba
Posts: 432
Joined: Fri Sep 30, 2022 12:11 pm

Re: How to insert text into a label

Post by CAsba » Wed Oct 05, 2022 11:42 am

A text field without borders.

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

Re: How to insert text into a label

Post by Klaus » Wed Oct 05, 2022 11:43 am

Well, the just use a text field and remove its borders (showborder = false).

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10097
Joined: Fri Feb 19, 2010 10:17 am

Re: How to insert text into a label

Post by richmond62 » Wed Oct 05, 2022 11:45 am

A label and a textField are different things.

Cairoo
Posts: 112
Joined: Wed Dec 05, 2012 5:54 pm

Re: How to insert text into a label

Post by Cairoo » Wed Oct 05, 2022 11:52 am

What Klaus said earlier is for changing the text of a button. For a label field, you would just

Code: Select all

...
put "some text" into field "your_label_here"
...
because in LC, labels are also fields.

CAsba
Posts: 432
Joined: Fri Sep 30, 2022 12:11 pm

Re: How to insert text into a label

Post by CAsba » Wed Oct 05, 2022 12:10 pm

Hi,
In 'edit script' I entered
...
put "Sales" into field "Field1"
...
The background color of the field is showing, it has no borders as prescribed, the text color selected is different to the background color, but the word does not appear.
(Btw, I should confess to my complete ignorance inasmuch as I was previously trying to edit the field by typing into it rather than scripting it; that's because I was working with VBA before.)

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

Re: How to insert text into a label

Post by Klaus » Wed Oct 05, 2022 12:15 pm

Hi CAsba,
CAsba wrote:
Wed Oct 05, 2022 12:10 pm
The background color of the field is showing, it has no borders as prescribed, the text color selected is different to the background color, but the word does not appear.
is the field "big" (wide/high) enough to display the complete text?
In 'edit script' I entered
And what script did you actually work on here?
It will not work in the namely fields script!
CAsba wrote:
Wed Oct 05, 2022 12:10 pm
(Btw, I should confess to my complete ignorance inasmuch as I was previously trying to edit the field by typing into it rather than scripting it; that's because I was working with VBA before.)
You can still do this in LC, click the "contents" button (second from left) in the inspector of your field and just start typing!

Best

Klaus

CAsba
Posts: 432
Joined: Fri Sep 30, 2022 12:11 pm

Re: How to insert text into a label

Post by CAsba » Wed Oct 05, 2022 12:21 pm

I entered
"...
put "Sales" into field "Field1"
..."

CAsba
Posts: 432
Joined: Fri Sep 30, 2022 12:11 pm

Re: How to insert text into a label

Post by CAsba » Wed Oct 05, 2022 12:24 pm

Many thanks, Klaus, the contents button is just what I needed ! Now it's all fine.

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

Re: How to insert text into a label

Post by Klaus » Wed Oct 05, 2022 12:40 pm

CAsba wrote:
Wed Oct 05, 2022 12:21 pm
I entered
"...
put "Sales" into field "Field1"
..."
the big question was: WHERE did you enter this?

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

Re: How to insert text into a label

Post by dunbarx » Wed Oct 05, 2022 5:38 pm

CAsba, and others.

I think the issue here is that a label field itself is a bit special. So though one can "put" a value into a label field, or "set" its text property, one cannot easily edit it.

CAsba, is this the issue? Because if you do not want to change the text of such a field under some sort of script control, even from the message box, then the only way to do so is through the object inspector.

Craig

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

Re: How to insert text into a label

Post by Klaus » Wed Oct 05, 2022 6:04 pm

Will move this thread to the Beginners section.

Post Reply