HTMLelement get text?

Not favoritedFavorited Favorited 0 favourites
  • 4 posts
From the Asset Store
Change delay, create new lines, "backspace" the text
  • I inserted an HTML element object, and I made it a text area:

    <textarea id="textarea"
     style="width:100%; height:100%; box-sizing:border-box;
     padding:8px; font-family:monospace; border:1px solid #888;">
    </textarea>

    But during preview, it seems like there's no way to actually get the text that the user types in that text area?

    Nor is there any way to get all of the changes that occur.

    Using the expression: HTMLElement.HTMLContent, will give ONLY the initial HTML (as seen above), not any changes that were made.

  • You can do it with scripting.

    Add event listener to that ID (make sure you wait for previous action if you are inserting your divs in runtime)

    const element = document.getElementById("textarea");

    element.addEventListener("change", (e) => {

    do something...

    you can run a C3 function like this:

    runtime.callFunction("functionName", param1, param2);

    });

    And get content like this:

    element.value

  • Also if you're just using it for a textbox, might as well use the "text input" object.

    Then you have a builtin event for changes and expressions for value.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • thanks, appreciate the help!

    Unfortunately I don't know how to do scripting, just events.

    It sounds like they didn't finish doing Event support for HTMLelement.

    Yeah I ended up just using textInput, that's invisible, and with a text object that displays the contents of the textInput, since the text object allows some decent customization and BBcode.

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