Re: Modal dialog without NSApplication
Hi, thank you very much for your answer, Rob. I am successfully using modal Cocoa windows in a plugin inside a Carbon application. This statement and your code gave me the final hint that it must work - and that the problem must be found somewhere else. Using your code nothing changed at all. In fact it would surprise me if using a loop with a session would be different to calling runModalWithWindow (concerning my problem I mean). So I again looked at the documentation - and here we are: do not send makeKeyAndOrderFront: to aWindow. But I called makeKeyAndOrderFront and you too. I removed the makeKeyAndOrderFront call in my old code - and everything works correct. Everthing? No - there is still one minor problem: if I hide the carbon application and activate it again then my modal window is updated. But not the current modal dialog of the carbon application (which calls my modal dialog via user action). Yes - I know. It is not good practice to show two modal dialogs. But this is the way the carbon application is doing it. And I can not change this. Any ideas how I can send a update to the carbon application? The problem here is that the NSApplication will receive the event - and will not update the carbon modal dialog. Cheers Martin Brodhage ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Modal dialog without NSApplication
On Sep 19, 2008, at 11:55 PM, brodhage wrote: No - there is still one minor problem: if I hide the carbon application and activate it again then my modal window is updated. But not the current modal dialog of the carbon application (which calls my modal dialog via user action). Yes - I know. It is not good practice to show two modal dialogs. But this is the way the carbon application is doing it. And I can not change this. Any ideas how I can send a update to the carbon application? Probably the Carbon app is using the older classic Mac OS style of handling updates for its Carbon dialog, rather than the modern Carbon events style. If that's the case, there's really nothing you can do. If the Carbon app used Carbon event handlers then this should just work automatically. -eric ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Modal dialog without NSApplication
On 19/09/2008, at 2:41 AM, brodhage wrote: I allready do. And then I call this function (within subclass of NSWindowController): - (void)showModalDialog { NSApplication *_app; NSWindow *_window; [self showWindow:nil]; _app = [NSApplication sharedApplication]; _window = [self window]; [_app runModalForWindow:_window]; } The modal dialog (displayed this way) blocks everything - it is not possible to close the modal dialog, hit any button or something else. For me it seems that the NSApplication:: runModalForWindow blocks all. So what I am searching for is to display the modal dialog without NSApplication. I am successfully using modal Cocoa windows in a plugin inside a Carbon application. Others have already spoken about the need for NSApplicationLoad() and setting up an autorelease pool, you definitely have to do both these things. To display the window I do this: //show the window [window makeKeyAndOrderFront:nil]; //start a modal session and wait for a response NSModalSession session = [NSApp beginModalSessionForWindow:window]; NSInteger response; for (;;) { response=[NSApp runModalSession:session]; if (response != NSRunContinuesResponse) break; // } //when the user exits the window, hide the window [NSApp endModalSession:session]; [window close]; You can hook up your OK/cancel buttons something like this: -(IBAction) ok: (id)sender { [NSApp stopModal]; } -(IBAction) cancel: (id)sender { [NSApp abortModal]; } You can then test for the return value of the NSModalSession and do whatever you want with the results. -- Rob Keniger ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Modal dialog without NSApplication
Hi, I am developing application software for Mac and Windows. Most of the code is developed using ObjectC - this way most of the code can be used for both OS. Only the OS depending stuff - like showing dialogs, menus... - is separated. The problem: how can I show and handle a modal dialog for MacOS X without NSApplication? Using NSApplication (and all the other classes) would mean to have a lot more code OS depending. Any ideas? Cheers Martin Brodhage ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Modal dialog without NSApplication
Le 18 sept. 08 à 15:12, brodhage a écrit : Hi, I am developing application software for Mac and Windows. Most of the code is developed using ObjectC - this way most of the code can be used for both OS. Only the OS depending stuff - like showing dialogs, menus... - is separated. The problem: how can I show and handle a modal dialog for MacOS X without NSApplication? Using NSApplication (and all the other classes) would mean to have a lot more code OS depending. Any ideas? Cheers Martin Brodhage If you just want to show simple dialog, you can use CFUserNotification. If you want a complexe dialog that require some custom control or event handling, you will have to use NSApplication. I don't understand why using NSApp for this kind of works will have an impact on the remaining of you application though. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Modal dialog without NSApplication
Hi, thank you very much for your quick answer, Jean-Daniel. If you want a complexe dialog... Yes. So I guess CFUserNotification does not help. I don't understand why using NSApp for this kind of works will have an impact on the remaining of you application though. Just because a lot of my code handles common task - and it is not guaranteed that there is a NSApplication at all. For example let's take a plugin for a carbon application - here there is no NSApplication. And: using NSApplication would mean to bind the code only to applications and to name all files .mm instead of .cpp - not usable if you want to build that under Win. Cheers Martin Brodhage ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Modal dialog without NSApplication
Le 18 sept. 08 à 16:15, brodhage a écrit : Hi, thank you very much for your quick answer, Jean-Daniel. If you want a complexe dialog... Yes. So I guess CFUserNotification does not help. I don't understand why using NSApp for this kind of works will have an impact on the remaining of you application though. Just because a lot of my code handles common task - and it is not guaranteed that there is a NSApplication at all. For example let's take a plugin for a carbon application - here there is no NSApplication. In theorie, you can safely call NSApplicationLoad() to instanciate an NSApplication before you use it, even in a Carbon App plugin (and then create you own auto release pool). In practice, there is some issues when running a modal Cocoa windows in a Carbon App (I remember some carbon-dev messages about it). But it's worth the try. And: using NSApplication would mean to bind the code only to applications and to name all files .mm instead of .cpp - not usable if you want to build that under Win. You don't have to name all files .mm, only the one that uses Cocoa (tthe one that is already Mac OS X specific). And both Visual Studio and Xcode provide some options to force the type of the file (to tell VS to compile .mm as .cpp or to tell Xcode to compile some cpp file as mm). ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Modal dialog without NSApplication
Hi, thank you very much again for your quick answer, Jean-Daniel. In theorie, you can safely call NSApplicationLoad() I allready do. ... create you own auto release pool I allready do. And then I call this function (within subclass of NSWindowController): - (void)showModalDialog { NSApplication *_app; NSWindow *_window; [self showWindow:nil]; _app = [NSApplication sharedApplication]; _window = [self window]; [_app runModalForWindow:_window]; } The modal dialog (displayed this way) blocks everything - it is not possible to close the modal dialog, hit any button or something else. For me it seems that the NSApplication:: runModalForWindow blocks all. So what I am searching for is to display the modal dialog without NSApplication. Any ideas? Cheers Ness ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]