Page 2 of 2

Re: Setting text into a button.

Posted: Wed Oct 05, 2022 5:55 pm
by stam
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…

Re: Setting text into a button.

Posted: Wed Oct 05, 2022 6:03 pm
by Klaus
Will move this thread to the Beginners section.

Re: Setting text into a button.

Posted: Thu Oct 06, 2022 10:15 am
by CAsba
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.

Re: Setting text into a button.

Posted: Thu Oct 06, 2022 10:38 am
by CAsba
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 ?

Re: Setting text into a button.

Posted: Thu Oct 06, 2022 10:54 am
by Klaus
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

Re: Setting text into a button.

Posted: Thu Oct 06, 2022 10:58 am
by CAsba
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.

Re: Setting text into a button.

Posted: Thu Oct 06, 2022 11:15 am
by Klaus
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.

Re: Setting text into a button.

Posted: Thu Oct 06, 2022 1:56 pm
by dunbarx
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

Re: Setting text into a button.

Posted: Thu Oct 06, 2022 2:01 pm
by dunbarx
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