scrollTop in Text input

0 favourites
  • 2 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • I have a problem that I don’t understand how I can read the scrollTop of the “Text input” object.

    For example, to read the scrollTop of an html element (take this html):

    <div id='coder' style='overflow-y:scroll;'>
    	CODE
    </div>
    

    we just need type like this js:

    const coder = document.querySelector("#coder");
    
    runtime.globalVars.CoderTop = coder.scrollTop;
    

    I tried to use this code for "Text input", but it doesn't work:

    const boxSTop = document.getElementById("TextBox");
    
    runtime.globalVars.BoxTop = boxSTop.scrollTop;
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • First, you need to pick the instance of the TextBox. With the getElement() method, you can get its DOM element. At this point, you can access the scrollTop property.

    const textInputInstance = runtime.objects.TextInput.getFirstInstance();
    const textInputDOM = textInputInstance.getElement();
    
    runtime.globalVars.BoxTop = textInputDOM.scrollTop;
    
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)