Re: ! HELP ME!!! I DON'T WANT TO LEARN CARBON!!!
Re: ! HELP ME!!! I DON'T WANT TO LEARN CARBON!!!
- Subject: Re: ! HELP ME!!! I DON'T WANT TO LEARN CARBON!!!
- From: email@hidden
- Date: Wed, 22 May 2002 09:13:48 -0700
Roger O'Brien <email@hidden> wrote:
|Is there anyway Carbon and Cocoa can *share* a window? Like lets say I
|have a window in my cocoa nib file. Is there anyway for a carbon file
|i write to access that window?
|
|Or vise versa, if i have a carbon nib file with a window, is there
|anyway for my cocoa files to access the window? Please Please help me!!
Jens Bauer wrote:
|Uhm, I don't know. -But why on earth do you want to do this ?
|You need to provide more information about it.
|If you are programming Cocoa, you should not need to use Carbon; it's
|optional, but it's not necessary.
It depends on what he's doing. There are still some Carbon UI elements which don't have Cocoa equivalents. Perhaps he wants to use one of them in an otherwise-all-Cocoa window. Perhaps he's trying put a Cocoa interface on something open-sourceish which uses a Carbon (or, basically the same thing, OS 9) window, and redoing the window in Cocoa requires a lot of work.
On the original question: Cocoa does support Carbon windows; at least, so the NSWindow documentation says. There is an NSWindow method initWithWindowRef: which takes a Carbon WindowRef. (Warning: from here on is guesswork.) Since Cocoa does acknowledge the existence of Carbon windows, it would seem reasonable that NSWindowController's initWithNibFileNamed: could be given a nib file containing a Carbon window. (It may not be true, but it is reasonable.) Even if NSWindowController can't handle a Carbon nib file itself, you could probably load the nib file directly (using the NSBundle methods), then create an NSWindowController using its initWithWindow: method.
Unfortunately, I suspect that what you'll end up with after all that is an inert window that does nothing but sit there and look pretty. The problem is that the AppKit classes (so far as I know) don't understand Carbon controls (the Carbon equivalent of NSViews). This means that AppKit won't know how to run a Carbon window. If this is the case (and, again, I don't actually know whether it is or not), then you'll still need to write Carbon code to run the Carbon window.
The tricky part there is in making the Cocoa and Carbon approaches to handling events work together. There is (to my knowledge) virtually no documentation on doing this. It may be trivial, though I doubt it. It may mean taking Cocoa events and faking the corresponding Carbon ones, which would probably be considerable work itself.
As always, the key question is, what are you trying to accomplish? What problem are you trying to solve by having Cocoa use Carbon windows? If we know this, we may be able to offer more specific suggestions, or propose a different solution that is easier to pull off.
Glen Fisher
_______________________________________________
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.