Implementing a Multi-View Preferences Window

Hello,

My ultimate aim is to get a multi-view preference panel working using as much Applescript (rather than Objective-C) as possible. I’ve seen this post about preference windows, but the link to the Xcode project was broken, and I thought that this might be an easier path…

I’ve found a class created by a developer named Dave Batton here, which handles much of the preference work, and he’s got a very helpful tutorial on how to integrate it into a Cocoa application. However, it is in Objective-C… I would like to use it in my Applescript Studio application, but I’m not sure how much of the code should be left in Objective-C and how much should be converted to Applescript (and I’m not sure how to convert it). If possible, I’d like the menu selection and preference window opening done in Applescript…

How should I to integrate this class with Applescript, and what code should I use?

Thanks,
Quill

Operating System: Mac OS X (10.5)

I’m not sure what the complication is for you. What are you trying to accomplish that can not be done using the views available to you in IB? Are you looking for a typical toolbar“with-multiple-panes-style preferences window? Does it need to be modular for some reason (like to accommodate bundle-based preferences)? Why can’t you set up a window like everyone else that has a toolbar, connected to a tab view…and then have views in that tab view that display your preferences? You can connect your controls to bindings and get a fairly complex preferences window pretty much for free.

I guess my question is, what are you trying to do that is UNIQUE, or that you believe can’t be done in ASStudio? If nothing, then you simply have to learn how to code in ASStudio and it all should be fairly straightforward. I can think of very little that needs to be done in another language or using technology other than applescript to design a basic preferences window. Despite your comments, I’m still not sure what you’re asking for. A preferences window is merely a regular window that happens to be connected to some form of database of settings. All of what you need to do this should be right in IB. Just create a window, start laying out your interface, and go from there.

You’ll get a lot of precise answers if you ask more precise questions. Start developing the window and ask questions as you run into obstacles. There’s really no “better way”.

Hello,

Yes, I’m just looking to create a standard preference window with a toolbar (like in Safari) that animates between each view. I have successfully created a toolbar (using Interface Builder 3) in a window, but how do I set up the toolbar so that each toolbar item acts like a tab? For example, in Safari, by default it’s set on “General””and its icon is ‘active’ (in Tiger, the background behind the icon is darker, and in Leopard, the background looks recessed). When you click on “Appearance”, the window changes to a different view, with now the “Appearance” icon ‘active’.

Also, in the other thread I mentioned in my original post, someone said that the animated resizing had to be done with Objective-C…

Thanks,
Quill

OK, thanks to the other preference window thread, I now have a window which has two toolbar items (“General” and “Advanced”), and when each toolbar item is clicked, the window does an animated resize to an appropriate size. Also, the icon for the current toolbar item looks selected.

However, when the window loads, I want the “General” toolbar item already selected. Looking through Apple’s “Applescript Studio Terminology Reference”, I thought the selected item identifier property would do the job. But when I run my application, the “General” toolbar item isn’t selected at all… What am I doing wrong?


on awake from nib theObject
	-- Make the new toolbar, giving it a unique identifier
	set documentToolbar to make new toolbar at end with properties {name:"document toolbar", identifier:"document toolbar identifier", allows customization:false, auto sizes cells:true, display mode:default display mode, size mode:regular size mode}
	
	-- Setup the allowed and default identifiers.
	set allowed identifiers of documentToolbar to {"general", "advanced"}
	set default identifiers of documentToolbar to {"general", "advanced"}
	set selectable identifiers of documentToolbar to {"general", "advanced"}
	set selected item identifier of documentToolbar to "general" -- Why doesn't this work?
	
	-- Create the toolbar items, adding them to the toolbar.
	make new toolbar item at end of toolbar items of documentToolbar with properties {identifier:"general", label:"General", image name:"NSPreferencesGeneral"}
	make new toolbar item at end of toolbar items of documentToolbar with properties {identifier:"advanced", label:"Advanced", image name:"NSAdvanced"}
	
	-- Assign our toolbar to the window
	set toolbar of theObject to documentToolbar
end awake from nib

Thanks,
Quill

Operating System: Mac OS X (10.5)