Thanks Jens. I solved the crash problem - I now call setReleasedWhenClosed
FALSE for the window and it seems helping. On the other hand now
runModalForWindow
increases retainCount! Why is that? It makes no sense to me.
Also the window still appears in background (code below) and cursor cannot
be changed.

Here's part of the code (it's an interface, so I just put out relevant
parts of the methods being used, MCocoaView is a custom view class):

        NSRect rect = MRectToNSRect(ctrl->GetSizeRect());
        desc.View = [[MCocoaView alloc]initWithMControl: ctrl WindowSystem:
winsys];

           // Create window.
            NSRect bounds = MRectToNSRect(MRect(pos.X, pos.Y, pos.X + sz.X
- 1, pos.Y + sz.Y - 1));
            NSUInteger style = NSBorderlessWindowMask;
            desc->Window = [[NSWindow alloc] initWithContentRect: bounds
                styleMask: style
                backing: NSBackingStoreBuffered
                defer: YES];
            [desc->Window setReleasedWhenClosed: FALSE];

            NSString *titlens = MStringToNSString(caption);
            [desc->Window setTitle: titlens ];
            [titlens release];

            [desc->Window setContentView: desc->View];

// Activate the process...
             ProcessSerialNumber ourPsn = {0, kCurrentProcess};
            //OSStatus status =
            SetFrontProcess(&ourPsn);
       [desc->Window makeKeyAndOrderFront: NULL];


[NSApp activateIgnoringOtherApps: TRUE];
        [NSApp runModalForWindow: desc->Window];

Thanks, Vojtech


Dne 1. listopadu 2011 5:27 Jens Alfke <j...@mooseyard.com> napsal(a):

>
> On Oct 31, 2011, at 6:00 PM, Vojtěch Meluzín wrote:
>
> I tried using runModalForWindow, but found following problems:
> 1) The method seems to release the window or something. If I don't call
> [NSWindow retain] before calling it, further calls lead to a crash.
> Therefore I cannot show subwindows.
> 2) It doesn't show and activate the window - in most cases the window
> appears in the background.
> 3) It cannot change cursor - [NSCursor set] does nothing.
>
>
> I think you need to show us the code you use to run the window.
>
> 4) The documentation says nothing about the problems above, but it states
> the processing stops any other processing in other windows, including
> timers, that's not a good idea.
>
>
> It puts the runloop into a different mode, and blocks user events aimed at
> other windows, which sounds like what you want. Whether timers run depends
> on what runloop modes they were registered with; but there are plenty of
> other cases where modal windows are run, so the host app has probably had
> to deal with those before.
>
> —Jens
>
_______________________________________________

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 arch...@mail-archive.com

Reply via email to