Two windows are focused at the same time

Hi everyone,

I was working on a way to switch actors during battle by manipulating the default javascript files, and actually managed to make it work.

However, when I open the window to select the actor who will replace the one battling, I still have the "ActorCommandWindow" focused and selected WHILE I'm choosing an actor on the second window.

Here is the screenshot :

http://puu.sh/v2axY/58ee5f4c6c.jpg

I can both choose an action (attack, use magic, etc.) and swap characters.

I simply copied/pasted another existing command, and replaced the variables inside by a new "SwitchActorWindow". The method activate() correctly give focus of the new window, but it's somehow not losing focus of "ActorCommandWindow".

I do am missing something, but I have no idea if it's about a "battle command list" I haven't noticed or something similar, maybe a specific method I haven't called.

I'm using the default Window_MenuActor, and using it the same way as in using an item or a skill on a teammate from the menu.

Just ask if you need any bits of additionnal info to help me fix this issue.

P.S. : I believe a sample of the script would prove to be helpful :

Spoiler
Code:
Scene_Battle.prototype.createAllWindows = function() {
    this.createLogWindow();
    this.createStatusWindow();
    this.createPartyCommandWindow();
    this.createActorCommandWindow();
    this.createHelpWindow();
    this.createSkillWindow();
    this.createItemWindow();
    this.createActorWindow();
    this.createEnemyWindow();
    this.createMessageWindow();
    this.createScrollTextWindow();
   //kohl - Adding battle command "switch"
   this.createSwitchActorWindow();
};
Code:
Scene_Battle.prototype.createActorCommandWindow = function() {
    this._actorCommandWindow = new Window_ActorCommand();
    this._actorCommandWindow.setHandler('attack', this.commandAttack.bind(this));
    this._actorCommandWindow.setHandler('skill',  this.commandSkill.bind(this));
    this._actorCommandWindow.setHandler('guard',  this.commandGuard.bind(this));
    this._actorCommandWindow.setHandler('item',   this.commandItem.bind(this));
   //kohl - Adding battle command "switch"
    this._actorCommandWindow.setHandler('switch', this.commandSwitch.bind(this));
    this._actorCommandWindow.setHandler('cancel', this.selectPreviousCommand.bind(this));
    this.addWindow(this._actorCommandWindow);
};
Code:
//kohl - Adding battle command "switch"
Scene_Battle.prototype.createSwitchActorWindow = function() {
   this._switchActorWindow = new Window_MenuActor();
    this._switchActorWindow.setHandler('ok',     this.onSwitchOk.bind(this));
    this._switchActorWindow.setHandler('cancel', this.onSwitchCancel.bind(this));
   this.addWindow(this._switchActorWindow);
};
Code:
//kohl - Adding battle command "switch"
Scene_Battle.prototype.commandSwitch = function() {
   this._switchActorWindow.refresh();
    this._switchActorWindow.setFormationMode(false);
    this._switchActorWindow.selectLast();
   this._switchActorWindow.show();
   this._switchActorWindow.activate();
};
Code:
//kohl - Adding battle command "switch"
Scene_Battle.prototype.onSwitchOk = function() {
   var index = BattleManager._actorIndex;
    var pendingIndex = this._switchActorWindow.index();
   if (index === pendingIndex) {
       SoundManager.playBuzzer();
   } else if (pendingIndex < 4) {
       SoundManager.playBuzzer();
   } else {
       $gameParty.swapOrder(index, pendingIndex);
       this._switchActorWindow.hide();
       this.updateStatusWindow();
       this._actorCommandWindow.activate();
   }
};

Scene_Battle.prototype.onSwitchCancel = function() {
    this._switchActorWindow.hide();
   this._switchActorWindow.deselect();
    this._actorCommandWindow.activate();
};
Activating a new window makes it active, but it doesn't deactivate the previous one. You'll have to deactivate the actor command window as well.
Thanks for your tip, I found a way to solve this.

Actually, the Scene_Battle class has a method "isAnyInputWindowActive". I added this._switchActorWindow.active inside the condition and it worked perfectly.

Here is the sample of the script :

Spoiler
Code:
Scene_Battle.prototype.isAnyInputWindowActive = function() {
    return (this._partyCommandWindow.active ||
            this._actorCommandWindow.active ||
            this._skillWindow.active ||
            this._itemWindow.active ||
            this._actorWindow.active ||
            this._enemyWindow.active ||
           //kohl - Adding battle command "switch"
           this._switchActorWindow.active);
};

Thanks again for your help, problem solved.

Original thread: https://forums.rpgmakerweb.com/threads/two-windows-are-focused-at-the-same-time.76532/