How do I get the text of a button?

Just started using Construct 2? Post your questions here

Post » Thu May 07, 2015 1:54 pm

Hello,

I want to replace different objects in C2 with code. It works perfectly but I do not know how to get the text of a button in order to set the text of a text object.

Imagine a button which text is set to test. Now I want to set the text of the text object to test as well (via code).

Like textobject set text = button.text or something like that.

Is that possible?

Thanks for any ideas!
B
3
Posts: 6
Reputation: 187

Post » Thu May 07, 2015 2:27 pm

It seems like button.text is not available.
You could ofcourse give the button an instance variable and set the text of the button to the instant-variable so you could later use button.variable to get the button-text.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu May 07, 2015 2:57 pm

Hello LittleStain,

I know that button.text is not available. That was the first thing that I had in mind. Since it is not available, I have made this post.

Thank you for your workaround idea. I have thought about it as well and will start implementing it. But I have around 600 buttons (very long story…). Therefore I am still open for alternatives.
B
3
Posts: 6
Reputation: 187

Post » Thu May 07, 2015 3:12 pm

600 separate button objects?
Why not 600 instances of 1 button object?
All you'd have to do is give them all the variable and on start of layout set the text to the variable.
Then on button clicked check the variable to see the function..

But I might understand it the wrong way..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu May 07, 2015 4:08 pm

No, I have 600 instances of one button (in differant layouts). But every instance of a button has a differant text set to it (within the properties). I have added an instance variable to the object and now I have to set the instance variable manuelly (for every instance) to the text property.

So every instance of the object exists in a layout and is not generated by code. If I could set the new instance variable to the text property, I could do that with the text object as well. The text objects (its instances) are generated by code and replace the button object or rather the instances of the button.
B
3
Posts: 6
Reputation: 187


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests