[JS] Disable Sprite Button/ClickHandlers temporarily?

megumi014

Veteran
Veteran
Joined
Mar 8, 2017
Messages
130
Reaction score
212
First Language
Spanish
Primarily Uses
RMMV
Hiya!

As the title says: is there any way to disable a sprite button temporarily? (And activate it later?) Like with this._randomWindow.deactivate(); but for the mouse input?

I'm trying to set up a couple of windows on the Title Screen, and I could disable the mouse alltogether but I'd rather not.

I found this piece of code so I gueeess it's possible but I just can't find the necessary word. I tried with invisible but it didn't exist xD

Code:
Sprite_Button.prototype.processTouch = function() {
    if (this.isActive()) {
        if (TouchInput.isTriggered() && this.isButtonTouched()) {
            this._touching = true;
        }
        if (this._touching) {
            if (TouchInput.isReleased() || !this.isButtonTouched()) {
                this._touching = false;
                if (TouchInput.isReleased()) {
                    this.callClickHandler();
                }
            }
        }
    } else {
        this._touching = false;
    }
};

Sprite_Button.prototype.isActive = function() {
    var node = this;
    while (node) {
        if (!node.visible) {
            return false;
        }
        node = node.parent;
    }
    return true;
};
 

Trace

A Rieri Fan :3
Member
Joined
Jun 7, 2014
Messages
10
Reaction score
9
First Language
Indonesia
Primarily Uses
RMMV
Hey, you can create another this.isActive() function but for that specific function

Code:
Sprite_Button.prototype.processTouch = function() {
    if (this.isActive() && this.isTouchActive()) { /////add this//////
        if (TouchInput.isTriggered() && this.isButtonTouched()) {
            this._touching = true;
        }
        if (this._touching) {
            if (TouchInput.isReleased() || !this.isButtonTouched()) {
                this._touching = false;
                if (TouchInput.isReleased()) {
                    this.callClickHandler();
                }
            }
        }
    } else {
        this._touching = false;
    }
};

//don't need to edit this
Sprite_Button.prototype.isActive = function() {
    var node = this;
    while (node) {
        if (!node.visible) {
            return false;
        }
        node = node.parent;
    }
    return true;
};

//new function
Sprite_Button.prototype.isTouchActive = function() {
    return this._touchActive;
};

//new activate and deactivate function for touch
Sprite_Button.prototype.activateTouch = function() {
    this._touchActive = true;
};

Sprite_Button.prototype.deactivateTouch = function() {
    this._touchActive = false;
};
so whenever you call this.deactivateTouch, you'll disable the processTouch temporarily

Hope this helps...
:kaohi:
 

megumi014

Veteran
Veteran
Joined
Mar 8, 2017
Messages
130
Reaction score
212
First Language
Spanish
Primarily Uses
RMMV
Thank you! That makes so much sense :D I made a conditional check on the title screen that worked around the problem, but it's way more efficient to modify the Sprite Button function itself :kaoswt: Thanks again!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

If you'll mind a bit, ElfKisser is the polar opposite of GoblinSlayer.
"Bury me as much as you want in this pain, I'll still rise to hug you again!"

Hero or masochist?

Lol these new tiles are looking cute. :B
Made with Country Woods (Available on the Store) and Country Woods II (w.i.p)
Turns out 4 layers is A LOT.
I noticed random Japanese dialogue in the FF7 remake while playing in English. More than once. Just now I saved a vid where Tifa spoke Japanese after a battle. We all make mistakes lol, this is kinda funny though

Forum statistics

Threads
99,631
Messages
967,478
Members
131,298
Latest member
PasalReturning36
Top