[Plugin] Change/Replace CSS ID of input form objects

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!
  • In order to solve an issue with selecting an <input> object (button, filechooser, etc.) based off from it's HTML CSS ID I created a simple plugin that would allow me to do so.

    Since I've received some requests for the plugin itself I'll release it here

    https://github.com/Thndr/c2-ChangeCSSID

    All it is, is a function with an Action to find the first instance of a field with the CSS ID of 'oldID_' and then replaces it with 'newID_'

       Acts.prototype.changeID = function (oldID_, newID_)
       {
          var file_ = $("#" + oldID_);
          file_.attr('id', newID_);
       };[/code:27qsytfr]
    
    [img="https://i.imgur.com/KDNavBP.png"]
    
    Due to the timing on how it works you have to have a fake delay/skip 1 step before the function if you are using it on complete.
    I have not tested this plugin when you already have <inputs> and you mass change them, but if you change them when they spawn there should be no conflicts of it attributing the value to the wrong object.
    
    Also make sure the page you embed the project doesn't use the same CSS IDs or there might be an issue as well, as I have no tested that.
    If anyone has a suggestion on how I can target specifically the object's HTML element without needing the old CSS ID then I could remove one line out of the two needed for this function, and it will provide better assurance the wrong element isn't selected.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Due to the timing on how it works you have to have a fake delay/skip 1 step before the function if you are using it on complete.

    Then you can simply use the wait action with a value of 0 (no need for 0.00001).

    Wait 0 will execute the following actions on the next tick of execution.

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