How do I get the text of a button?

0 favourites
  • 5 posts
From the Asset Store
Change delay, create new lines, "backspace" the text
  • 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!

  • 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.

  • 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.

  • 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..

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)