Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subviews become disabled when title bar is hidden

Tags:

macos

cocoa

Writing app in XCode for OSX using OSX 10.8 SDK. All of my Windows work fine, until I use Interface Building to get rid of the title bar in the nib (I uncheck the Title Bar param on the Attributes Inspector of the window element). The windows still show, but all the subviews are disabled. I can no longer input text and process bars are all greyed out.

Does anyone know why this is happening? and how to have a Window without a title bar, but with all subviews enabled?

Here is what my view looks like with a title bar: enter image description here

And here's what it looks like without: enter image description here

As you can see, everything is disabled.


Update

Someone asked about code to display windows. For this example I didn't use any code. For the two screens above here are the steps I followed:

  1. Created a new cocoa application using XCode. (Automatically creates a xib).
  2. Dragged out two controls (Text field and progress bar) onto the existing window.
  3. Ran, and took a screen shot
  4. Closed and checked off the Title Bar attribute for the window.
  5. Restarted the app. Took the second screen shot.
like image 551
Jason Avatar asked Jul 22 '13 03:07

Jason


1 Answers

There is an answer for this question at this link:

Xcode 4, Cocoa Title bar removing from interface builders disables textView from editing

If you read the documentation for NSWindow you can see that the methods canBecomeKeyWindow and canBecomeMainWindow return NO if there is no title bar. Sub-classing NSWindow and over-riding these methods will make it so they can become key windows.

There is sample code on how to subclass these windows in apple's documentation website, or in xcode if you have documentation installed.

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindow_Class/Reference/Reference.html#//apple_ref/occ/instm/NSWindow/canBecomeKeyWindow

Search for canBecomeKeyWindow in the above link and there will be sample code included that will help explain the process.

like image 171
trueinViso Avatar answered Dec 09 '22 09:12

trueinViso