Forum Discussion

HoneyTurner's avatar
HoneyTurner
Community Member
5 days ago
Solved

Capturing Text from a Shape or TextBox

I have a game with 40 questions, subdivided into 4 categories. I've created an object for each category and used states for each question within the category. My current plan is to enter the question...
  • Nathan_Hilliard's avatar
    4 days ago

    I am confused by your setup description, but I suspect that you expect the text within a slide shape to be contained in the object's value property. Text in a Storyline object, especially formatted text, is generally embedded into an SVG element, broken down into text groups based on the formatting applied. You could extract the text, but not simply. The text is also represented in a hidden part of the page called the shadow-DOM.  If, for example, you had a button with a text label of "Press Me", and the object was defined by

    const button_1 = object("6UNtrp5jRD9")

    you could potentially extract the text value by identifying the corresponding button element in the shadow-DOM, and then accessing the innerText property. For example:

    // Use the object ID as identified by Storyline, and append 'acc-' to the beginning to obtain the element's ID in the shadow-DOM.
    
    let buttonText = document.getElementById("acc-" + "6UNtrp5jRD9").innerText
    
    //This would return the value 'Press Me' to the variable buttonText