User Data

UserData in MightyEditor is a way to store specific data of an object. It works similarly to HTML5 localstorage, where you assign key->value pairs to an object.


Accessing and changing the values is done by using the object.getData().userData.key method:

"use strict"; = {
    create: function() {

        this.text = mt.create("Text");
        this.count = mt.create("count");

        this.addClick = mt.create("add");
        this.addClick.inputEnabled = true;

        this.result = mt.create("result");
        this.result.inputEnabled = true;


    update: function() {
        //calls functions on mouseclick, this);, this);


    //adds 1 to the value for 'click' key
    addCount: function() {
    //gets the stored data and resets it
    showResult: function() {
        var newCount = this.count.getData();
        this.count.getData() = 0;

Full sample available here.

Leave a Reply

Your email address will not be published. Required fields are marked *