Hey Guys,
i got an old applescript Xcode application here (pure Applescript & IB), working in Xcode 3.2.6.
The task is to polish the look of it. But as i dont want to rewrite thousands of lines of (working) applescript code, i am mostly polishing the IB interface. And - in addition - im a noob in Object C.
I added a Custom window class (found somewhere here) - see below - which allows me to have any shape of the window i want without a titlebar (with an image as background). Unfortunately cause of the titlebar is gone now, i cant minimize the window with this applescript command
set minituarized of window "main" to true
So i guess i need to call a method somehow (but via applescript command). And this is where i could need your help guys.
CustomWindow.m
#import "CustomWindow.h"
#import <AppKit/AppKit.h>
@implementation CustomWindow
// This line initializes any window connected to the CustomWindow class as titleless...overriding the default AppKit init method.
- (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag {
// Call the NSWindow method to instantiate the window, but add the borderless mask to make it titleless
// Sets 'result' as a variable reference to the new window object
NSWindow* result = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
// Set the background color to clear so that (along with the setOpaque call below) we can see through the parts of the window that we're not drawing into
// If you want to have a window with a non-rectangular shape, un-comment the next line.
[result setBackgroundColor: [NSColor clearColor]];
// Note: You'll need to provide an image in an image view in the window that will server as your 'window', otherwise the window will just be invisible.
// The next line makes the window float on top of all other windows. Uncomment it if you wish the window to remain on top of ALL other windows.
//[result setLevel: NSStatusWindowLevel];
// Note: this is useful for startup screens or other utility windows that only you should control
// Control the transparency of the entire window. 0 is totally transparent... 1 is totally opaque.
[result setAlphaValue:1.0];
// Control Opaqueness. Leave "YES" to make it a "normal" window.
// Set to "NO", and use in conjunction with the 'clearColor' background color above to make a window with a custom graphic shape.
[result setOpaque:NO];
// Does the window has a shadow?
[result setHasShadow: YES];
// Automatically center the window? Position will be handled as any normal xcode window would be if this is not used.
[result center];
return result;
}
// Custom windows that use the NSBorderlessWindowMask can't become key by default. Therefore, controls in such windows
// won't ever be enabled by default. Thus, we override this method to change that.
- (BOOL) canBecomeKeyWindow
{
return YES;
}
CustomWindow.h
/* CustomWindow */
#import <Cocoa/Cocoa.h>
@interface CustomWindow : NSWindow
{
NSPoint initialLocation;
}
@end