Dennis
Dennis

Reputation: 3596

Objective C, HUD Panel?

I have a HUD Panel which has couple buttons, a label, and a textfield where a user can input. Right now it works perfectly fine, except I want to get rid of the title bar. It is really easy to get rid of the title bar, as I can just uncheck the "Title Bar" in the interface builder. The problem is, when I get rid of the title bar, it becomes un-editable, so the user cannot type in anything in the textfield. Why is this, and how could I fix it?

I know I could write a custom window by myself programmatically, but I really just need to remove the title bar and I have everything else set up with the builder already, so I wanted to find a simple way to fix this problem, (hopefully) if there is any.

Thanks in advance.

Upvotes: 0

Views: 1213

Answers (2)

Justin Boo
Justin Boo

Reputation: 10198

All You need to do is:

Subclass Your NSPanel and override canBecomeKeyWindow as rdelmar mentioned.

You can do it like this:

create panel class:

.h

@interface panel : NSPanel {

}

@end

.m

#import "panel.h"

@implementation panel

-(BOOL)canBecomeKeyWindow
{
    return YES;
}

@end

Don't forget to change panel's class to Your created class in identity inspector.

enter image description here

Upvotes: 1

rdelmar
rdelmar

Reputation: 104082

You need to override canBecomeKeyWindow and return YES.

From the docs: The NSWindow implementation returns YES if the window has a title bar or a resize bar, or NO otherwise.

Upvotes: 1

Related Questions