Creating a pro-looking preference pane in AS Studio


Is is possible to create a professional looking preference pane with AS Studio application without paddling thru the tough upstream current of Objective-C and Cocoa?

Or better still, are there known utility apps that would enable one to create a preference panel " a la" pref pane that one usually sees in commercial apps?

I tried binding preferences but it is still limited in functionality.

Thanks for any input.

archseed :slight_smile:

Not strictly AppleScript, but maybe this will help

Hi Lambo,

Thanks for the link.

I have actually seen that tutorial before - it’s quite good but I thought I’d still have to burn some night lights trying to get it done via the Cocoa way, let alone understand the whole thing. Guess I’ll just have to dig in and learn some Objective C and Cocoa. Shucks!

Thank you, just the same.


So are you talking about a toolbar with selectable items that reveals tab view items which may or may not invoke animated window resizing? Because if you are, you can do everything but the window resizing with ASStudio and AppleScript. You can even have an intermediate tab view that displays the indeterminate progress wheel while the transition between tab items takes place.

For the animated resizing, you’ll want to look into the setFrame:display:animate: method for the NSWindow class. Back when I messed around with this, I remember setting up a simple Obj-C class that was basically an intermediary to this method. I sent it the window and the new size as parameters and it worked rather well. The biggest hassle was compensating for the presence or lack of the toolbar. I think it involved a bunch of complicated checks for the toolbar mask (icon size, if it displayed icons and text, icons only, or text only, etc) and then adjusting the new window size accordingly.

Thinking about it now, you should be able to determine the new window size with AS and use the “call method of object” function on the prefs window and send it the necessary parameters, which are just a new frame (which I believe is a list of four numbers describing the bottom right origin point with the first two numbers and the frame’s width and height with the second two numbers) and two booleans, which would both be true.

I don’t have the time to test all this but if you’re reluctant to dig into Cocoa, you might want to look into this. And if I can dig up the old code at home where I experimented with this (and it’s both usable and understandable), I’ll post it.


Indeed, I am thinking of a preference tool bar with tab view items.

It would be nice to have it animated, adjusting window sizes as the need comes, but if it takes a deeper comprehension of Cocoa and Obj-C, that’s probably for my next step, not right now.

If you can post codes that I could learn from, simply using AppleScript and AppleScript Studio, with perhaps (may I repeat perhaps?) a little of Obj-C method calls as you mentioned, that’d be great. I am sure are quite a few people in this forum who would want take a look and learn from your codes.


archseed :slight_smile:

Well, looking back on my old code and doing some new experiments, it looks like I tried my last suggestion of calculating the new window size in AS and simply calling the setFrame:display:animate: method of the window object but I couldn’t, and still can’t, get it to work. The Obj-C code is simple enough though.

This goes in the implementation file of the Obj-C class (e.g. WindowController) that you add to your project. So when you want to resize your preferences window you use something like:

call method "resizeWindow:toSize:" of class "WindowController" with parameters {window "prefs", newSize}

… where the variable newSize is a list with the first number being the new width and the second number being the new height. When using call method, the list gets coerced into an NSSize struct, so the Obj-C code can easily work with the passed parameter.

Setting up the toolbar is a little more code that I prefer to post here so I’ve just put together an example Xcode project. It has selectable toolbar items which have corresponding tab view item sizes so when each toolbar item is clicked, the tab view switches to the new tab view item and resizes the window to the appropriate size.

This is just to give you an idea of how to do this so I didn’t implement the load tab view item as an interim view while the new tab view item is prepared before switching to it. But it’s not that tough to set up.

Now, I haven’t tried to match System Preferences which fades the current view out while the new view fades in. It’s certainly possible, though you would need to use more Cocoa. And it’s a little beyond what I’ve explored in Obj-C so far.

Hope this helps.


Thanks for the help.

I will certainly explore what you have offered as tips and perhaps, dig in a little bit on Obj C and Cocoa, to see if I can begin to make sense on the codes that you posted, as well as your example. With a little patience and hard work, perhaps I can manage.

Will keep you updated how far I can get on this problem in this very same post.

Am truly grateful.

archseed :slight_smile:

I’m just keeping this thread alive with a big thank you for the example project. I’m adding it to my /Developer/Examples directory.

I also liked your implementation of an associative array.

The link to the Xcode project seems to be broken (the site is still there, but the Xcode project file doesn’t seem to exist in that location)… Could Joseph post a new link, or does someone have the file they could email me?


I would try contacting him via the “Contact” link on his website.

Unfortunately, the contact email address bounces. Does anyone else (Krunk?) have a copy of the project that they could send me?