Re: Drag And Drop Killed By loadNibNamed
Christiaan Hofman <[email protected]> Thu, 1 Dec 2011 13:12:07 +0100
| Newsgroups | gmane.comp.macosx.devel |
|---|---|
| Message-ID | <[email protected]> |
On Dec 1, 2011, at 12:42, Alexander Reichstadt wrote: > I remember to have run into the same problem. Somehow the window was = not present early enough. I ended up using NSWindowController's >=20 > [[yourwindowcontrollersubclass alloc] = initWithWindowNibName:@"YourNibNameWithoutExtensionNib"] >=20 > which worked. >=20 >=20 > Am 01.12.2011 um 11:25 schrieb SD: >=20 >> Hello all, hope you can help. >>=20 >> My application loads a window from a nib and then displays it. This = window has a Text View (NSTextView in NSScrollView). >>=20 >> When the window is loaded from a nib using: >>=20 >> [NSBundle loadNibNamed:@"nibfilename" owner:m]; >>=20 >>=20 >> dropping text (using drag and drop) on the NSTextView doesn't work. >>=20 >> It doesn't seem to matter how I show the window once I load the nib. = Have it show via "Visible At Launch", show using makeKeyAndOrderFront, = show using beginSheet. >>=20 >> If I copy the window into my main nib show it, then drag and drop = works fine. Does anyone have any ideas why the drag and drop is getting = killed when I use loadNibNamed. >>=20 >> Thank you. I cannot tell you why you experience this problem. For one, I think you = are leaving out the crucial information about why this happens. I = expect, but have no way of knowing, that this may be a timing issue, so = you may be showing the window too early in the process. Have you tried = loading at (much) different times? It seems that there is a problem with = registering drag types, so have you actually checked those? You = certainly should check all those things and more.=20 As a general matter, you should (almost) always use one of the four nib = loading classes (or subclasses) NSWindowController, NSViewController, = NSDocument, or NSApplication to do the loading for you. It does what you = do plus some more things that you (and I) don't know about but that can = be important (for instance binding-to-owner bugs). You should have very = good reasons to side step that. Moreover, you should be pretty = knowledgable and experienced to know lots of difficult pitfalls to avoid = (like this ones) before you should embark on doing your own nib loading. = I must say that from your post I don't get the impression you are = sufficiently qualified or have good enough reasons. So my strong advice = is simply: don't do this. Christiaan