Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

CaptainZap

macrumors regular
Original poster
Jan 17, 2007
170
0
I created a NSWindow subclass and all I did was add this method (You can probably do all this without subclassing it but it works)
Code:
- (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag
{
	self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
	return self;
}
In the .nib file I added a Window with a textfield and made all of the connections. When I run the app the window is drawn without a title bar but you can't edit or click on the text field... Anyone have any idea why?
 
You might need to tell your window subclass to use the text field as the initial first responder:
Code:
[myWindow setInitialFirstResponder:myTextField];

Dunno, just guessing really...
 
Okay. I'm just starting out here with Objective-C and from reading up last night what you're doing at the moment is redundant in initWithContentRect. If initWithContentRect is a function in NSWindow then just call it directly and do not override the function like you have done.
 
Why are you creating an NSWindow subclass? I've never done so myself...

Becuz i r bad prgrammer =D. But really I was just messing around and was trying to make a window without a titlebar. Anyone know a better way to accomplish this?

Okay. I'm just starting out here with Objective-C and from reading up last night what you're doing at the moment is redundant in initWithContentRect. If initWithContentRect is a function in NSWindow then just call it directly and do not override the function like you have done.

But I'm calling the super function of it... It works. I'm just trying to figure out the textfield...

Look, I'm not that crazy xD http://developer.apple.com/samplecode/RoundTransparentWindow/listing6.html
And that even answered my question, all I needed to add was this code to my subclass
Code:
- (BOOL) canBecomeKeyWindow
{
    return YES;
}
 
Becuz i r bad prgrammer =D. ...
But I'm calling the super function of it... It works. I'm just trying to figure out the textfield...
True, it does work. But since you're not doing anything else or special in that function it's not needed because your class inherited it from NSWindow.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.