Skip navigation.
 
mlRe: Subclassing NSOutlineView causes failure of window to become main or key
FROM : John Stiles
DATE : Mon Mar 03 00:08:25 2008

Is anything printed to the Run Log or Console?

Dennis Hartigan-O'Connor wrote:
> I'm trying to use a subclass of NSOutlineView to allow merged columns,
> so that some cells can run over their bounds, using methods I read
> about at:
>
> http://www.mactech.com/articles/mactech/Vol.18/18.11/1811TableTechniques/index.html
>
>
> I have four instances of my custom subclass organized in an NSTabView.
>
> I have the rather strange problem that my program runs, without
> crashing, and displays the tables with merged columns just as I
> desire.  However, the main window fails to become either main or key,
> so no input is accepted from the user.
>
> I've done a lot of work trying to diagnose this problem and I have two
> key results:
>
> 1) Using NSOutlineViews, everything works fine.  In particular, by
> using windowDidBecomeKey and windowDidBecomeMain methods, I find that
> the main window becomes both key and main, and accepts user input, and
> everything works fine.
>
> 2) In an attempt to diagnose this problem, I created an "empty"
> subclass of NSOutlineView, which behaves exactly the same as
> NSOutlineView, because no methods are overwritten.  Here's the really
> strange part.  If I set ONE OR THREE of my four NSOutlineViews to the
> custom "empty class", everything works fine--the application runs just
> as if I were using four NSOutlineViews.  windowDidBecomeKey and
> windowDidBecomeMain are both called.  If I set TWO OR FOUR of my four
> NSOutlineViews to the custom "empty class", then the main window fails
> to become either main or key and no input is accepted. 
> windowDidBecomeKey and windowDidBecomeMain aren't called.
>
> Believe it or not, I've actually been able to make everything work by
> adding a FIFTH instance of my custom subclass (providing merged
> columns) to the window and setting it to be hidden.  When I do this,
> my whole application works great, with merged columns.
>
> In short, my custom subclasses are somehow preventing my main window
> from become key or main--but only when I use an even number of
> instances of such subclasses.  When I use 1, 3, or 5 instances,
> everything is fine.
>
> I am running Xcode 2.4.1 on OS 10.4.  I have already set the Nib file
> format to "Pre-10.2", because I've heard that newer formats can cause
> problems with custom subclasses.
>
> I know that this is a strange story...I hope that there is a simple
> explanation that will make me look stupid.  My application is working,
> but I just can't stand having to use such a blatant kludge as a hidden
> instance of my custom subclass.
> _______________________________________________
>
> Cocoa-dev mailing list (<email_removed>)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>

Related mailsAuthorDate
mlSubclassing NSOutlineView causes failure of window to become main or key Dennis Hartigan-O'… Mar 2, 21:16
mlRe: Subclassing NSOutlineView causes failure of window to become main or key John Stiles Mar 3, 00:08
mlRe: Subclassing NSOutlineView causes failure of window to become main or key Dennis Hartigan-O'… Mar 3, 02:15