Thanks for your quick reply, and thanks for the information. It's good to know you can't mix Carbon and Cocoa within the same window. That had never occurred to me! Looks like I'm getting a crash course in Mac GUI APIs.
I'll do as you suggested and look into CHBrowserView next. Hopefully I'll be able to reuse as much of my code as possible.
Thanks again,
Brad
Kevin Ollivier wrote:
Hi,
Cocoa and Carbon are only somewhat compatible, and what you're trying to do in this case won't work. You can't mix Carbon and Cocoa controls in a window, i.e. you can't have a NSView with Carbon-based children. If you want to use Carbon, you'll have to create the window using Carbon and use all Carbon controls in the window. Note that you can mix them at the window level - that is, you can have both Carbon and Cocoa windows in an application. You simply cannot mix Cocoa and Carbon within a particular window.
My suggestion would be to figure out what is wrong with the Cocoa embedding process. Have you taken a peek inside CHBrowserView to see how it works? My guess is that its simply a wrapper around the XPCOM APIs to simplify embedding in Cocoa. Hopefully someone more familiar with Cocoa can give more information (I work primarily with Carbon).
Kevin
On Apr 20, 2004, at 12:26 PM, Brad Fish wrote:
Hi,
I'm hoping there are some Mac experts out there that can help me out with this one. I'm trying to embed Mozilla 1.6 into a Mac OS X Cocoa application. As far as I understand it, there are three different options (some of which may or may not work):
-Mozilla (--enable-default-toolkit=cocoa) -Mozilla (Carbon) -CHBrowserView
I have some Win32 code that utilizes standard Mozilla embedding stuff that I've ported to Mac OS X with only minor changes. It compiles under Mac OS X successfully. When I link it against Cocoa Mozilla, the browser window initially appears, but doesn't seem to respond, and my app soon crashes or hangs. When I link it against the standard Carbon Mozilla, my code seems to successfully create the browser window, but the only thing that appears is a blinking keyboard cursor (presumably where a form field should be appearing). I haven't yet looked into CHBrowserView, because that would require writing new embedding code in Objective-C, and I would like to utilize my existing code on the Mac.
My basis for trying to embed Carbon Mozilla in Cocoa comes from the fact that my Cocoa Mozilla build doesn't seem to work very well (painting problems in particular). Apparently CHBrowserView works fine under Cocoa, but again, I would like to use my existing embedding code. I'm using Mac OS X 10.3, and according to docs on Apple's developer site, Carbon and Cocoa should be able to coexist within the same application. I am retrieving the Carbon WindowRef from the parent NSView and passing that into the embedding code. Not much shows up other than that cursor I mentioned.
Do any Mac Mozilla gurus know embedding Carbon Mozilla in a Cocoa app is possible? If so, is there anything special I need to do to allow them to play nice together? Or, has anyone embedded Cocoa Mozilla successfully? I'm not an experienced Mac programmer so I'm unsure how to proceed. I'm wondering if it may have something to do with threading issues as well. My Win32 DLL launches a new thread (to act as the primordial, main UI even thread) where all the embedding initialization and event loop are located. My browser window is created from another thread via XPCOM proxies. Under Win32, my thread runs a standard Windows message loop. Under the Mac however, I'm simply getting my thread's nsIEventQueue and calling EventLoop on it, since I understand that all widgets share the same main event loop on the Mac (is this an incorrect assumption?).
Thanks in advance for any help. Please let me know if I've been unclear in any way or need to post additional information.
Brad Fish [EMAIL PROTECTED] _______________________________________________ mozilla-embedding mailing list [EMAIL PROTECTED] http://mail.mozilla.org/listinfo/mozilla-embedding
_______________________________________________ mozilla-embedding mailing list [EMAIL PROTECTED] http://mail.mozilla.org/listinfo/mozilla-embedding
