Setting text into a button.

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

stam
Posts: 2682
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Setting text into a button.

Post by stam » Wed Oct 05, 2022 5:55 pm

I think this is probably one of those blind spots, so to help you get out of it:

Create two buttons. Set their names in the property in properties inspector (note: their names, not their label). Name one “action” and one named “payButton”.

To stop the button “payButton” from displaying its name as its label, put a space into its label. Now you should have two buttons, one with the text “action” and one with no text.

Edit the script of button “action” and copy paste this text into it:

Code: Select all

On mouseUp
   Set the label of button “payButton” to “Raise an invoice”
End mouseUp
Now the “payButton” button should have the text “Raise an invoice”. Hope that makes sense…

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Setting text into a button.

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

Will move this thread to the Beginners section.

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

Re: Setting text into a button.

Post by CAsba » Thu Oct 06, 2022 10:15 am

The issue is now solved. I mistakenly copied, pasted and positioned a number of buttons prior to naming and coding them. I think this must have caused a problem, as, when I deleted them all and started again with just one button, it seemed to work.

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

Re: Setting text into a button.

Post by CAsba » Thu Oct 06, 2022 10:38 am

Hi Stam,
Sorry to say that I just tried your method, and got as far as one button showing 'action' and the other blank, but it remained blank after I entered the code in 'Action' and closed 'Action' and made a couple of mouseclicks.
But, I just tried a new button, in Inspector I entered 'Trial' as name, and 'Tryout' as label, and it worked, the button shows text 'Tryout', so I guess everything's fine now, anyway. Or am I still missing something ?

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Setting text into a button.

Post by Klaus » Thu Oct 06, 2022 10:54 am

Hard to say from afar...

If you like you could send me your stack and I will take a look, send it to: klaus AT major-k.de

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

Re: Setting text into a button.

Post by CAsba » Thu Oct 06, 2022 10:58 am

Hi Craig,
Thank you for taking the time to make up and send your illustration, I appreciate it.
Yes, it DID work, I got 'fish' in the lower left button. However, when I changed the code to act on BB it did not work, 'BB' remained 'BB'.
I then deleted the stack and ran it again from the download, and this time it DID NOT work, 'AA' remained 'AA' after clicking on 'setelable'.
There are things happening here that truly mystify me, not to say shake my confidence.

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Setting text into a button.

Post by Klaus » Thu Oct 06, 2022 11:15 am

To add to your confusion, I did the same with this script and it worked as exspected:

Code: Select all

on mouseUp
   set the label of btn "BB" to any word of "cat dog mouse bird fish slug ant"
end mouseUp
I changed the foreground color of that button to white, black was hard to read.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9660
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Setting text into a button.

Post by dunbarx » Thu Oct 06, 2022 1:56 pm

CAsba.

I am speaking for myself and the others.

There is something very simple that is going on with your stack. It derives from the fact that you are just learning LC.

One day soon you will see it, as we will.

In the meantime, we will keep working. Are you really saying that my stack once worked, and now does not? That is a different issue.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9660
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Setting text into a button.

Post by dunbarx » Thu Oct 06, 2022 2:01 pm

CAsba.
when I changed the code to act on BB it did not work, 'BB' remained 'BB'.
How did you change the code? And remember, if you read my handler, it is entirely possible to press the "set label" button several times and still get the same label in the target button. Right? That is because there are only a handful of options, selected at random, and the same one might come up again. Like rolling a die.

Can you try this? Change the working line to:

Code: Select all

 set the label of btn "AA" to "XYZ" && random(9999)
Now at least that issue goes away. :wink:

Craig

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”