Application launch from plugin
Application launch from plugin
- Subject: Application launch from plugin
- From: Laurent Michel <email@hidden>
- Date: Mon, 4 Jul 2005 18:01:46 -0400
Hi,
I have a legacy application implemented in C++ and it supports a
plugin architecture which allows me to write shared libraries and
have the application call functions within the shared lib. Most of
the time, the application is console only (no UI at all).
I wanted to use the plugin facility to create a Cocoa shared lib that
would provide a UI when it is needed. The shared lib links against
the cocoa framework (and foundation). The application is Multi-
threaded, but fortunately, I can ask to have the main thread call
into the plugin. I managed to write a demo plugin that loads a nib
file and pops up a window with the application. The application even
responds if I click on the buttons.
However, I have the following problems
1. The application menu never shows up
2. The application seem to remain 'inactive' or 'unfocused' (the
title bar remains the inactive shade of grey). I also noticed that
nothing shows up in the CTRL-TAB switcher for this application.
In a sense, it it like starting the main() of the application much
later from a shared lib that refers to all the proper libraries with
the correct thread. The application itself of course remains a
console app.
I presume that I have not initialized something properly. At this
point, the entry point in the plugin (executed by the main thread is
pretty straightforward and quite short)
- It calls _objcInit()
- It calls NSApplicationLoad() (return value is true)
- It calls app = [NSApplication sharedApplication]
- It uses [NSBundle loadNibFile ... ] to load a nib file
- It calls [app run]
As I said, _most_ of it works, but - menus are missing and the
application appears to be inactive despite the fact that I can indeed
click on button and get responses from the UI.
I noticed that, even after receiving the applicationDidFinishLauching
notification, the mainWindow and
keyWindow methods of NSApplication keep on returning NULL. However,
the application appears to have a mainMenu and a serviceMenu (as
reported by the corresponding methods). Finally, if I write a dummy
cocoa _application_ that loads the same nib file with the same code,
it works fine (mainwindow focuses, menu does show up).
Any pointer on how to handle this properly is greatly appreciated.
Thanks a lot (and sorry for the long mail).
--
Laurent
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden