How do I trigger On text changed when I set input box's text via events?

0 favourites
  • 6 posts
From the Asset Store
Forget about default textbox restrictions, you can create sprites atop of the textbox
  • How do I trigger On text changed when I set input box's text via events?

    When I type in the box, it triggers, but when I set the text via events, it doesn't..

    how do I trigger it?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The actions you are running for on text changed event, add them to the set text event.

  • The actions you are running for on text changed event, add them to the set text event.

    No.

    That is not possible in my case.

    I'm looking for a way to trigger the event.

  • Okay, I solved my problem:

    I wanted to press up and down to adjust textbox values for numbers, and when setting the value it wouldn't trigger events.

    I needed to add "this.oninput()" which triggers the on change events.

    using execjs

    "$(document.getElementById('number')).on('keydown', function(event) { 
     if(event.which==38){
     this.value=parseInt(this.value)+1;
     event.preventDefault();
     this.oninput();
     }else if(event.which==40){
     this.value=parseInt(this.value)-1;
     event.preventDefault();
     this.oninput();
     }
    });"
  • actually it doesn't work completely since it gets the id, and only selects one of the elements.

  • okay this works for multiple text inputs with same IDs

    "$('[id=""number""]').on('keydown', function(event) { 
     if(event.which==38){
     this.value=parseInt(this.value)+1;
     event.preventDefault();
     this.oninput();
     }else if(event.which==40){
     this.value=parseInt(this.value)-1;
     event.preventDefault();
     this.oninput();
     }
    });"
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)