Multiple Window Example?

I’m trying to build an app where, to start with, I’d like to build a Preferences Window that opens when I select “Preferences” from the menu bar.

I’m looking for a nice multi window example.

Should I be making a seperate NIB file for each window or just adding windows to the main nib? In either case, how do I actually open the windows? I’ve tried “open window” and setting the window to visible but both result in error, so I guess I’m not connecting the extra windows correctly.

I know how to connect the window contents up to my script, I just can’t get the darn things to open up.

I seem to do all kinds of things with one window, its been great. I’d like to get out of the shallow end of the pool though.

This should help if you’re using a single NIB:

You could also make a menu item and connect that to a script like this:

show window "whatever"

It looks like keeping things in one nib file will work. I’d love some more elaborate examples though. Thanks for your help.

Also, I found this:

This wouldn’t be a problem for most Studio apps though.

Am I able to pass the result of opeing a window and its operations to a variable.

on mouse up theObject event theEvent
	if the name of theObject is "ChooseSource" then
		set string value of text field "source" of window "Preferences" to findFolder()
	end if
	if the name of theObject is "ChooseTarget" then
		set string value of text field "target" of window "Preferences" to findFolder()
	end if

	if the name of theObject is "browserSelectButton" then
		return "theSelectedObject"
	end if
	if the name of theObject is "browserCancelButton" then
		hide window "browser"
	end if
end mouse up

on findFolder()
	show window "browserWindow"
(* how do I make this function return the value *)
	return "???"
end findFolder

What’s in this “browser” window, and what do you want it to return? It sounds like you want to use the open panel.

Well what do you know. Open panel is exactly what I needed. I was doing it the hard way. Thanks for that.

I’m still curious, in a more general since, whether or not you can set a function to return the result of a set of window operations. This may be thinking too much along the lines of a web application where information is comming from a get or post operation. But I can imagine someone may want a function which opens a window and returns the submitted information into a variable.

What is being submitted? Keep reading, then ask questions if you’d like more information.

You can display dialog in either the standard way or attached to a window, and you can also display a window/panel attached to another window (if you need more choices). Information on all of this can be found on that same page that I linked to above; It describes the Panel Suite.