Set TextInput in javascript

0 favourites
  • 2 posts
From the Asset Store
10 Beautiful Pokemon-like Building Pixel Art Sprite Sets
  • I have been using a very old javascript Pop-up Calendar with TextInput for years. It worked fine in C2, and I thought it was working in C3, but I have a strange problem...

    when I click on the TextInput, the Calendar pops up fine, I can select a date by clicking on it, and it looks like it updates the TextInput's Text value. But C3 doesn't realise that the value has changed.

    I made a quick test file to illustrate the problem:

    - the TextInput field has a default value, click on the Button and the TextInput value is added to the Text object on the right.

    - click on the TextInput field, select a different date

    - Click on the Button again, and the TextInput value hasn't changed, even though it is displaying the new date.

    if you manually start to edit the TextInput value, it then uses the new value.

    Is this a bug in C3? or is this a problem with the old javascript?

    The TextInput value gets set in the tcal.js f_tcalUpdate function. the browser's DevTools shows the value changing, but C3 still has the old value

    https://www.rieperts.com/games/forum/PopCal.c3p

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • if anyone stumbles across this in the future, I ended up filing a bug report:

    https://github.com/Scirra/Construct-3-bugs/issues/4255

    Because of worker mode, there is no easy way for this to be fixed. The solution Ashley suggested was to dispatch the input event after updating the value in javascript.

    const elem = document.getElementById('input1');
    elem.value='test 1 2 3';
    elem.dispatchEvent(new Event("input"));

    This works great, and has the added benefit of causing the "On Text Changed" trigger to fire.

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