setModal() to force current modal window to be modeless?

Don’t you think that method setModal() shall force current modal window to be set modeless? I believe it’s natural behavior for changing modal state.
Now according to the logic of window object it is necessary to unset modal state for current modal window before setting modal state for new one. Do you think it’s normal to do it manually? Is there any reason for that separation of methods?

Such a logic of modal windows was done intentionally. And we think that it is normal to finish working with the current modal window and then show another window.

Current logic is “blind” for any cases where several modal windows called sequentially.
Let’s say there is a dialog that opens in modal state.This dialog has input which on click calls another dialog in modal state where some selection may be done and then to be return into previous dialog which should keep modal state. Current logic does not provide such a natural behavior for modal windows and to do it manually is very complicated to track modal state from outside of window object. Furthermore current logic for widows set does not seem to work as a set as soon as they do not “see” or “know” each other. If it is implemented as a window set I believe they should work as a “team”.
To be exact I would like to suggest some corrections to the current code. It’ll affect few methods but will solve all these issues regarding modal state. It won’t break current logic, but will only complete it. Also it will solve the issue with modal screen behavior on hide() method called that I mentioned in one of my previous posts.
Here are these corrections:

  • method setModal():

win.setModal = function(state) { if (state == true) { //if (that.modalWin != null || that.modalWin == this) return;//!!!ORIGINAL CODE LINE TO BE TAKEN OUT ////////////////////////////////////////// if (that.modalWin == this) return;//CORRECTED LINE ////////////////////////////////////////// that._setWindowModal(this, true); } else { if (that.modalWin != this) return; that._setWindowModal(this, false); } }

  • method _setWindowModal():
this._setWindowModal = function(win, state) {
	if (!this.modalWinsAr) this.modalWinsAr = new Array();
	if (state == true) {
		if (this.modalWinsAr.length>0){
			curModalWin = this.wins[this.modalWinsAr[this.modalWinsAr.length-1]];
			curModalWin.KeepInModalWinsAr = true;
		if (this.modalWinsAr.length == 0 || this.modalWinsAr[this.modalWinsAr.length-1] !== win.idd) this.modalWinsAr.push(win.idd);
		this.modalWin = win;
		win._isModal = true; = win.zi - 2; = ""; = win.zi - 2; = "";
	} else {
		this.modalWin = null;
		win._isModal = false; = 0; = "none"; = 0; = "none";
		if (!win.KeepInModalWinsAr){
			if (this.modalWinsAr.length>0){
				var prevModalWin = this.wins[this.modalWinsAr[this.modalWinsAr.length-1]];
				while (!prevModalWin && this.modalWinsAr.length>0){
					var prevModalWin = this.wins[this.modalWinsAr[this.modalWinsAr.length-1]];
				if (prevModalWin){
			win.KeepInModalWinsAr = false;
  • method _hideWindow():
this._hideWindow = function(win) {
	if (this.modalWin == win) this._setWindowModal(win, false);
	//////////////////////////////////////////////////////////// = "none";
	if (win.checkEvent("onHide")) {
		win.callEvent("onHide", [win]);
	} else {
		this.callEvent("onHide", [win]);
	var w = this.getTopmostWindow(true);
	if (w != null) {

Of course it is only rough idea and the code above requires deep verification.
If you are not interested in this - that’s fine. In that case please disregard my post then. Hope somebody else on this forum may need it.

Thanks for the provided solution. We will consider it.