Re: NSWindow: initWithWindowRef
Re: NSWindow: initWithWindowRef
- Subject: Re: NSWindow: initWithWindowRef
- From: Evan Gross <email@hidden>
- Date: Tue, 12 Feb 2002 20:01:08 -0500
On 2/11/02 4:09 PM, "email@hidden" <email@hidden>
wrote:
>
Hey,
>
Has anyone ever tried to use the initWithWindowRef, i just don't know how to
>
use it. In fact i need to create a window to work with its windowRef, in a
>
Cocoa application.
>
I really need help !!!
>
Thkx
>
I've used it (out of necessity, due to a (mis)behavior of Cocoa
NSPanel-as-floating-utility-windows in BGOnly apps deactivating the active
app's window whenever you click the title bar of the NSPanel - but I
digress) to implement a window containing Carbon controls.
I'm not exactly sure what information you're after, but I was able to create
a Carbon nib file and load it manually from a NSWindowController subclass
using something like the following (excuse any potential dumb line
wrapping):
error = CreateNibReference(@"CarbonWindowNibName", &theNibRef);
(check for error)
error = CreateWindowFromNib(theNibRef, CFSTR(@"MyWindowNameInTheNib"),
&theWindowRef);
(check for error)
[self setWindow:[[NSWindow allocWithZone:[self zone]]
initWithWindowRef:theWindowRef]];
After you do this, you can (and probably have to) install
CarbonEventHandlers to deal with any controls in the window (you can't use
Cocoa widgets) and possibly even to handle window-related events.
It seems to be ok to call *certain* NSWindow and NSWindowController methods
(for example, NSWindowController's -showWindow -window, and -setWindow
methods seem to work, but don't bother trying to use
-setWindowFrameAutosaveName. Likewise, you can call certain NSWindow methods
(-isVisible seems to work, as does -orderOut, -display, -setFrame), but
there are likely others than won't work or shouldn't be called.
Don't expect to get many, if any, NSWindow or NSWindowController delegate
methods or notifications.
Anyway, hope this helps, I asked the list a similar (albeit more detailed)
question some time back, but pretty much had to figure things out just by
trying various combinations of Carbon/Cocoa calls to get the results I
required. There's basically no documentation on the actual details of using
-initWithWindowRef.
Your mileage may vary.
Evan Gross
Rainmaker Research Inc.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.