floating palette with user-definable opacity

Hi All,

I would like to implement a floating palette in my application whose opacity can be varied and could bear data but don’t know how to go about it.

I do not even know what to call it. I did a search in this form and found floating panel and floating window which are probably not the same as the floating palette that I have seen in some Cocoa-based applications. Or am I wrong about this?

Your help is greatly appreciated.




This can get you started (adjust window name, alpha value -0.0 thru 1.0- as needed):

--> alpha-ize
tell window "whatever"
	set opaque to false
	set alpha value to 0.7

--> floating-ize
call method "setWindowLevel:useLevel:" of class "methods" with parameters {window "whatever", "NSFloatingWindowLevel"}
--> use "NSNormalWindowLevel" to restore


Credits go to Jonathan Nathan for the "setWindowLevel:useLevel:" method knowledge


The term “palette” really only refers to a conceptual design element. Essentially, it’s a collection of tools or elements that the user can easily access. There is no “NSPalette” object, if that’s what you’re after. A palette would most likely be either a NSPanel, set as a ‘utility window’ in IB, or a custom subclass of NSWindow that you can draw to appear however you’d like. By subclassing NSPanel or NSWindow, you can get a lot of functionality or appearance modifications that you otherwise can’t get in ASS alone.

Edit: looks like jj beat me to this one. :slight_smile: As jj states, you can set the level to NSFloatng WindowLevel. You can also (in a custom subclass) initialize the window using the “NSBorderlessWindowMask”, which will cut off the title bar, window background, etc. Essentially the window is a blank slate that only displays the elements you put in it. You can draw a custom background using an image, and then add elements to it to get the layout you want. Let me know if this is of interest to you and I can pass on some code. Edit: Check out this page for a bit of (cluttered) sample code. :rolleyes:

As far as the opacity of the window goes, this should be all you need…

set theAlpha to .8 --> 'theAlpha' must be a number from 0.0 to 1.0
set alpha value of window "Main" to theAlpha

If you’re planning to release this publicly, just be careful that you don’t go too crazy setting the alpha value of a typical window. If you’re going to create a unique window style that strays from the usual titlebar/content view approach, this may be an OK practice… but setting the alpha to anything other than 1 for a normal window under normal circumstances is not generally expected or desirable. Perhaps while the window is not frontmost or the app is inactive, but not while the user is expected to click on it or read from it.


Thanks a lot jj and jobu. As always, you’ve been particularly helpful.

Let me gather myself together and see if I opened myself a can of esoteric stuff or not. I will try to experiment with thestuff you’ve kindly given and see how far I can go with creating the floating window or panel (thanks jobu for the clarification) with the appearance that I want.

I will let everyone in this forum know how far I got. And thanks for the offer of further help.

More power to you!

archseed :slight_smile:


Here’s an update on my little “trial and error” run using the codes suggested by jj and jobu.

The opacity issue is resolved for me. Using the code posted by jj, with credit to Jon Nathan, I could create a window with varying color and opacity. The only change I did was to add another line “update” to make sure that the window shows the new settings. Without the “update”, I could not see the new opacity and color settings.

Now, I am also interested on the tileless window and had tried to study and try Jon Nathan’s tileless window project. His project compiles and runs as is in my Xcode but I get a report of 2 incompatible issues… the error mentions about some problem with the objective-C pointer.

I haven’t yet tried jobu’s tutorial on creating customWindow class and creating tileless window using his code. I will do that shortly.

Thanks for helping this AS Studio newbie. BTW, I know nothing about objective-C to tinker with Jon’s code. May be Jon could review his tileless project and provide an update for later OS/Xcode? Just a thought.

archseed :slight_smile:

Hi All,

What do you know? I spoke too soon about Jon Nathan’s tileLessWindow project not working in a more recent version of Mac OS X and Xcode.

Actually, it does work. If I can get Jon to let me post his AppleScript code here I will show the revised version. It’s really very very minor that I am even ashamed to tell you but it’ll save you from doing all the “trial and error” runs that I did.

There are other things, however, that I found I needed to do to obtain the tileless window and to make it work properly. I also found essential to combine jobu’s “customWindow” creation tip which I filled easily with Jon’s objective-C codes for customWindow.h and customWindow.m

Possible to post your AppleScript code for tilelessWindow, Jon? I think it’s short enough to post and will definitely be useful for those in this forum who want to use tileless window in their application, with varying color and opacity to boot. I needed that and now I am quite happy that I have the thing working.



Correction please.

tileLessWindows should be titleLessWindows. Pardon me.

archseed :|:(:rolleyes:

Sure, post it.


Here’s a revised version of the project updated for Xcode 2.1 that allows you to choose on-the-fly whether or not your windows are titled (bordered) and/or textured (metal); properly allows the windows to become key; and allows for dragging the windows by their backgrounds when no titlebar is available:



Hi Jon,

That’s great! Gotta download your latest and check it out.

It was a great learning experience to study your titleLessWindows code. I can appreciate better what you guys do for the rest of us. And, it made me feel good and felt like I have accomplished something by getting your previous codes to work when it wouldn’t the first time.

Ciao. And many many thanks!

archseed :smiley:

Hi Jon,

I still need to learn more Xcode…no doubt about it.

I downloaded your updated titlelessWindow project but could not get any of the files you have in the project folder to open in Xcode. I notice that it’s extension is not .xcode so I guesst that may be expected.

Is there anything I must do to get your project to open in Xcode? Or, should I build a new project using your script and the accompanying objective-C codes for the customWindow and the controller?

Thanks for the help.

archseed :):frowning:

Hi Jon,

Back to you quickly. I have been busy trying to make your latest titleLessWindow version to work. After some more studying of your codes and tinkering around, I finally got it to work with one main window.

Basically, all I did was:

  • create a new project
  • clicked on the main window to create the customWindow and the windowController
  • open the .h and .m files for the customWindow and the controller
  • paste your objective-C codes in their respective places
  • paste your AppleScript codes and modify it to work with just one window
  • connect the main window to the script
  • build and run

And it worked (titleless and movable window; and, variable opacity and background color). Oh, I made the source window (“main”) to be invisible at launch so that no background window is left behind when the titleless window is moved around.

This is great stuff Jon. Many many thanks. It just made my AppleScript Studio life more colorful and exciting (not an exaggeration BTW).

archseed :smiley: