Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cocoa/OSX - NSTextField not responding to click for text editing to begin when titlebar is hidden

I have a NSTextField in my window (added with IB) with a hidden title bar but when I click on it when the app is running, it does not respond or place a cursor in its field. Is there anything I am doing wrong? it is setup in the most standard way possible, an editable textfield on a window.

Thanks.

like image 621
Zigglzworth Avatar asked Dec 22 '22 08:12

Zigglzworth


1 Answers

Create a custom class that inherits from NSWindow, and set it as the NSWindow Object in InterfaceBuilder. Then override the following methods:

//
// canBecomeKeyWindow
//
// Overrides the default to allow a borderless window to be the key window.
//
- (BOOL)canBecomeKeyWindow
{
    return YES;
}

//
// canBecomeMainWindow
//
// Overrides the default to allow a borderless window to be the main window.
//
- (BOOL)canBecomeMainWindow
{
    return YES;
}
like image 183
Brandon Horst Avatar answered May 11 '23 02:05

Brandon Horst