Closing first non modal window closes all windows

In my solution, running on MacOS X, a form (let’s call it “form A”) is opened in a non-modal window. It has a series a buttons to open other forms. When I open one or more forms in non-modal windows and then close form A hitting the red close button ALL open windows close. This doesn’t happen if I close any other window: they close regularly leaving the other windows open, including Form A.

Besides that, form A always stays behind the other forms, while, if I click on any other one, the clicked form becomes the frontmost one.

All windows are named. Is this the expected behavior? And why the first non modal window behaves differently from the others?

Servoy Developer
Version 3.5.2-build 515
Java version 1.5.0_13-119
Mac OS X 10.5.1

Hi rioba,

I cannot reproduce this problem.

Is there any chance that you can post the code used to open the dialogues and let us know more background on things like onLoad, onOpen or onHide etc properties on any of the fomrs … or can you produce a small solution which demostrates this behaviour :)

Cheers
Harry

Harry,

I’ll try to post a small sample solution asap. In the meantime, this is some of the code I use:

To open the first form (fm_chgFormWin, a form with 4 buttons to open other forms) in a non modal window:

application.showFormInDialog(forms.fm_chgForm,-1,-1,-1,-1,"Choose Form",false,false,"win_fm_chgForm",false);

(this method is fired by clicking on the splash screen of the first form of the solution)

Associated to the onShow event of this first form is a global method which is also associated to the onHide event of all the forms opened by the first form. This method toggles the enabled state of the buttons of the first form: if a form is opened in a window, the respective button is not enabled

for(var g in forms.allnames)
	{
			//if the form is open the button is not enabled and the text changes color to gray
		if(application.isFormInDialog(forms.allnames[g]) && forms.allnames[g].substr(3,2) == "bt")
			{
				forms.fm_chgForm.elements["bt_" + forms.allnames[g].substr(6)].enabled = false;
				forms.fm_chgForm.elements["bt_" + forms.allnames[g].substr(6)].fgcolor = "#cccccc";
			}
			//if the form is closed the button is enabled and the text changes color to red
		else if(forms.allnames[g].substr(3,2) == "bt")
			{
				forms.fm_chgForm.elements["bt_" + forms.allnames[g].substr(6)].enabled = true;
				forms.fm_chgForm.elements["bt_" + forms.allnames[g].substr(6)].fgcolor = "#ff0000";
			}				
	}

Each button of the first form is named according to the forms to be opened, (e.g. form “fm_bt_warehouses” is opened by the button “bt_warehouses”) and has the following method associated

application.showFormInDialog(forms["fm_" + application.getMethodTriggerElementName()],-1,-1,-1,-1,"Form " + application.getMethodTriggerElementName(),true,false,"win_fm_" + application.getMethodTriggerElementName(),false);

	//set the button state according to the open forms
globals.gb_mt_showHide();

I should add to my previous post, that if I use a method to close the forms, the behavior is the same of clicking on the close button of the form.

I still could not find an explanation to the behaviour described in my previous post, that is: the first open non modal window closes all open non modal windows when it is closed, either by clicking on the red close button in the upper left corner of the form (I’m referring to Mac OS X, I did not try in window) or by clicking the close button on the form which has this method associated with “on Action”. Closing other windows has no effect on any other open window.

application.closeFormDialog("win_fm_chgForm");

I enclose a small sample solution. Thank you for your help.

nonmodal.servoy (7.71 KB)

rioba,

When you open a window from another window, the second window acts as a child window of the one that originated the open call.
This hierarchy causes the behaviour you described, the parent cannot be placed above the child window and closing the parent closes all its children.

Rob

Rob,

thanks for the explanation. So it is not my code that is wrong.

rioba