Why can't I get focus in NSPanel if the "Title Bar" is not installed?

If I create a project in Xcode 4.1 and ask MainMenu.xib to have two NSPanels and put an NSTextField in both panels, if I set one of NSPanels so as not to display a โ€œtitle barโ€, then the text box within this panel cannot be clicked or got focus.

Why??

+6
source share
1 answer

A window (or panel) without a title cannot become a key, so it cannot get focus. You must subclass it and override its method - (BOOL)canBecomeKey , for example:

 @interface MyPanel : NSPanel @end @implementation MyPanel - (BOOL)canBecomeKeyWindow { return YES; } @end 
+9
source

Source: https://habr.com/ru/post/897094/


All Articles