MZ Back button in new Window_Base

Hi all,

I'm working through the new MZ codebase, and I figured I'd start from the beginning this time rather than trying to cobble together the advanced stuff first (which I probably should have done from the start when working with MV. Oops).

I've made a new class which inherits from Window_Base. I'm able to get the blank window to show up, but there is also a back button which appears in the top-left hand corner. This back button appears to have no functionality. Does anyone know how to pass it a method, and does anyone know how I may remove this back button, should I need to?

JavaScript:
function NP_Window_TestWindow() {
    this.initialize.apply(this, arguments);
}

NP_Window_TestWindow.prototype = Object.create(Window_Base.prototype);
NP_Window_TestWindow.prototype.constructor = NP_Window_TestWindow;

NP_Window_TestWindow.prototype.initialize = function(rect, onClose) {
    Window_Base.prototype.initialize.call(this, rect);

    this._onClose = onClose;
}

NP_Window_TestWindow.prototype.destroy = function(options){
    Window_Base.prototype.destroy.call(this, options);

    this._onClose.call(this);
}

1599332762897.png
The buttons are turned on/off by players in game with ConfigManager.touchUI (or the touch UI option in the in-game options menu). They are created mostly in Scene_MenuBase not the window. You can also redefine the needsXButton methods in any class that inherits from Scene_MenuBase (example: make a method in your scene called yourScene.prototype.needsCancelButton and have it return false). This would turn it off for just that scene rather than the whole game.

They are Sprite_Button and can support setClickHandler for methods that are called when they are clicked. If they don't have any methods passed to them, they call Input.virtualClick and Input handles it as the respective button (cancel for example is handled as if you hit the cancel button since it does not need any special methods). So if your window had a cancel handler, the cancel touch button would call that as it is interpreted as if you had pressed the cancel button on the keyboard/gamepad.
The buttons are turned on/off by players in game with ConfigManager.touchUI (or the touch UI option in the in-game options menu). They are created mostly in Scene_MenuBase not the window. You can also redefine the needsXButton methods in any class that inherits from Scene_MenuBase (example: make a method in your scene called yourScene.prototype.needsCancelButton and have it return false). This would turn it off for just that scene rather than the whole game.

They are Sprite_Button and can support setClickHandler for methods that are called when they are clicked. If they don't have any methods passed to them, they call Input.virtualClick and Input handles it as the respective button (cancel for example is handled as if you hit the cancel button since it does not need any special methods). So if your window had a cancel handler, the cancel touch button would call that as it is interpreted as if you had pressed the cancel button on the keyboard/gamepad.
Thanks Casper, that was exactly what I was looking for! For the benefit of anyone else coming across this in the future, here is the solution that I have now:

JavaScript:
NP_Scene_TestWindow.prototype.create = function() {
    Scene_MenuBase.prototype.create.call(this);
    this._cancelButton.setClickHandler(this.popScene.bind(this));
    this.createTestWindow();
}
Hi I know this is an old thread but may I ask howd you manage to fix it?

this._cancelButton.setClickHandler doesn't work on mine, can't still press the Cancel Button

Original thread: https://forums.rpgmakerweb.com/threads/back-button-in-new-window_base.126816/