2
votes

I open a new webview window by call createWebviewWithRequest. And it opens well. But I have an issue.

When this webview window is close, my window app is closed too. Here is my code to open new webview window

- (WebView*)webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request
{
    originRect = appDelegate.window.frame;
    [[webview mainFrame]loadRequest:request];
    return webview;
}

- (void)webViewShow:(WebView *)sender
{
    // set size window app to origin rect
    [appDelegate.window setFrame:originRect display:YES];
}

The webview has a Submit button. When user click on this button, webview will be closed.

How can I prevent my window app is not closed when the webview window is closed?

Do you have any ideas?

2

2 Answers

0
votes

I solved this problem by handling in webViewClose of webview UIDelegate. In webViewClose, I make the window is key and front

See my code in below:

- (void)webViewClose: (WebView *)wv
{
    [window makeKeyAndOrderFront:wv];
}

When I call this, it works.

0
votes

This code in your NSApplication delegate (or subclass) should do a proper job:

- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication
{
    return(NO);
}

-It will allow you to have 0 windows open. You could combine it with the solution you already mentioned, but I recommend adding these 4 lines to your NSApplication delegate/subclass, in order to do things the right way.