Re: Cocoa window messages in app being ported from Carbon
Re: Cocoa window messages in app being ported from Carbon
- Subject: Re: Cocoa window messages in app being ported from Carbon
- From: Uli Kusterer via Cocoa-dev <email@hidden>
- Date: Sat, 10 Aug 2019 23:38:00 +0200
> On 10. Aug 2019, at 23:02, Kurt Bigler <email@hidden> wrote:
> Currently if I call NSApplicationMain instead of my regular Carbon event loop
> (which is based on ReceiveNextEvent), NSApplicationMain returns immediately.
> I don't call NSApplicationMain immedately because there is scads of
> initialization that I do without relation to incoming events.
NSApplicationMain looks at your Info.plist to decide which Cocoa NIB to load
at startup and what your NSPrincipalClass is (usually NSApplication). If you
haven't set up your app as a proper Cocoa app, NSApplicationMain will be
unhappy and won't work. Every time I've ported a Carbon app to Cocoa so far, I
basically moved the main() function's contents (except the call to
RunApplicationEventLoop()) into applicationDidFinishLaunching: etc. in an app
delegate. Then it usually worked as before.
ReceiveNextEvent() seems a bit of an odd choice. In general, you want
RunApplicationEventLoop() and timers, performSelector:afterDelay:0.0 or threads
to get processing time reliably for other things during the event loop.
> This makes me wonder about NSApplicationLoad, which I do call.
NSApplicationLoad() is basically the "turn a Carbon app into enough of a Cocoa
app to run Cocoa code"-call, so shouldn't be needed in a fully Cocoa app. And
your guess why NSApplicationMain didn't work was pretty close, I think.
Cheers,
-- Uli Kusterer
http://www.zathras.de
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden