one more question about background color...

If I have a window that is “textured”-- brushed metal look…

and then I define this:

	set background color of window "window" to "white" 
	tell window "window" to update

The brushed metal becomes white…

is there a way to set it back to brushed metal?

I tried “transparent”… but that didn’t work…

-patrick

Window masks are set when the window is initialized. You cannot change them after creating the window. Once it’s metal, it’s metal forever.

http://www.cocoabuilder.com/archive/message/cocoa/2004/2/4/96061

Hmmm… So it’s just my imagination that I turned a brushed metal window white?

Because I really did it from within my program…

-p

Misread the original post. But for discussion’s sake, I’ll elaborate on what I was talking about.

You altered the background colour. That isn’t the same as altering the window mask.

http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindow_Class/Reference/Reference.html

NSWindow/NSPanel’s -initWithContentRect: methods allow you to specify the window style mask, one of which can be NSTexturedBackgroundWindowMask. (You can logical OR multiple masks together.) When you flip the textured button in Interface Builder, this is the same thing. Notice how there is no way to alter the style mask after initializing the window.

As far as your question, I don’t see anything in NSColor or NSWindow that will give you the metal texture pattern, so I wouldn’t be shocked if you can’t reset the metal.

Why are you changing the metal to white, out of curiosity?

Edit: You might try saving the background colour of the window before altering it, then resetting it. I dunno if AppleScript will handle the require retain on the NSColor for you, however.

Well… I was just experimenting with coloring a window (no real good reason), and wanted to see how to ‘uncolor’ it.

I believe I tried setting a variable to the current window’s color and then setting it back to that, but I got an error…

-p

  1. There’s no such thing as “un-colouring”. If you want to remember the colour, that’s your responsibility. (It’s an issue of efficient memory usage. If you’re going to change it, why should the window remember automatically?)

  2. Stop saying you “got an error” (as you did here and in another thread). TELL US what error you got instead. Being vague will only get you vague answers.

Hi,

For Metal window:
call method "_setTexturedBackground:" of window "mainWindow" with parameter 1
For Aqua window:
call method "_setTexturedBackground:" of window "mainWindow" with parameter 0

Titanium,

afaik ‘_setTexturedBackground:’ is a private method … so you should note that it might not work any longer for future OS releases …
And I don’t think it is a solution for patrick’s problem at all. (At least here it doesn’t remove a set backgroundColor from an NSWindow.)

Patrick,

I played a little bit but I haven’t found an AppleScript solution for this. So here a short NSWindow category for your problem
(add .h and .m to your project and use it with a simple call method ):

[code]// file: NSWindow RemoveColorAddition.h
#import <Cocoa/Cocoa.h>

@interface NSWindow (RemoveColorAddition)

-(void)removeColor;

@end[/code]

[code]// file: NSWindow RemoveColorAddition.m
#import “NSWindow RemoveColorAddition.h”

@implementation NSWindow (RemoveColorAddition)

-(void)removeColor{
[self setBackgroundColor:nil];
}

@end[/code]
and call it from your script:

        tell window "main"
            call method "removeColor" of it
            update
        end tell

Hope that helps,

Dominik