Hey everyone,
First I want to apologize since I know this has come up multiple times but I can’t quite wrap my head around it using the posts of others.
I am using Xcode to build a cocoa AppleScript application and I’m not sure how to change the color of the main window that pops up. Mainly I want to change the alpha of the window (not necessarily the things inside it) and add a blur if it’s possible. I want the window to be more Yosemite-esque
I’m not sure if I need to use an Interface Builder Outlet or if I just need to send some info to the default property “theWindow” but some help would be very very appreciated!
it sounds like what you’re after is the new vibrancy feature, which requires NSVisualEffectViews. It’s not quite as simple as setting a background; you also need to use special colors for text fields in the views, for example.
I suggest the best place to start is to have a look at the WWDC videos on the subject, to get a good grasp of what involved before you start trying to code anything.
You’re correct! I will do that. My main issue is I am not sure if the Obj-C can be used in the cocoa-applescript applications. I’ll start watching right away.
As I learn about this I’m going to add the information here so if anyone else comes across this they can use it:
(You’ll need a free developer account to access these areas)
WWDC Video
Sample Code from Apple
You can mix the two freely, if that’s what you mean.
I got it working. It was actually much simpler than I had thought. For future reference, in the Interface Builder is where NSVisualEffectsWindow can be found. The important part is making sure that the layers are set up right, but it’s actually much simpler than I had expected.
Right – just make sure you app runs only under Yosemite. If you need to support earlier versions, you need to check the OS version at run time, and make the change in code.
Yeah, I have a 10.6 version in the works.
Thanks for your help. Last thing, you said that ObjC and AppleScript can work together. Do I need like a main.m or can I write it in the AppDelegate above or below the script? Because I was looking into NSColor etc and thinking of implementing that.
You can do it in your app delegate class.
So I have gotten everything figured out except one thing.
I am using the following code to tell the app to check for NSVEV before bringing up the window so it can load the old window if necessary.
if ([NSVisualEffectView class])
{
// OS X 10.10 code here.
}
else
{
// OS X < 10.10 code here.
}
From here.
Using this script, my first thought would be to plug in a call for the 10.10 window in the top and a call for the older-style windows in the bottom, but I’m not sure that’ll do the trick.
Example:
if ([NSVisualEffectView class])
{
*use primary xib file*
}
else
{
*use secondary xib*
}
I don’t know that that will work. You may well have to do the whole vibrancy thing in code rather than Xcode if you want to support older versions of the OS.
That’s what I was thinking as well. If I find a solution I’ll report back.