Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Another crazy Objective-C question

Another crazy Objective-C question
Thread Tools
Professional Poster
Join Date: Sep 2000
Location: Texas
Status: Offline
Reply With Quote
May 28, 2004, 06:23 PM
 
Ok, anyone know how to have a window appear when you click on the icon in the dock? All windows will be closed at this point. I figure it needs either a connection in IB or a makeKeyAndOrderFront statement somewhere in the code... Thanks!
     
Fresh-Faced Recruit
Join Date: Mar 2004
Status: Offline
Reply With Quote
May 28, 2004, 06:50 PM
 
I assume that you mean that all of the application windows were explicitly close (as opposed to minimized) and that you would like clicking on the icon to open up a new window. Have you tried the NSApplication delegate method -applicationDidBecomeActive? Then instantiate the new window in that method. Or maybe that is not the aspect of the problem you are concerned with?
     
Addicted to MacNN
Join Date: Nov 2002
Location: Seattle, WA
Status: Offline
Reply With Quote
May 28, 2004, 08:19 PM
 
As I understand it the preferred place for this code is:
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
Sent by theApplication to the delegate prior to default behavior to reopen (rapp) AppleEvents. These events are sent whenever the Finder reactivates an already running application because someone double-clicked it again or used the dock to activate it.
     
Professional Poster
Join Date: Sep 2000
Location: Texas
Status: Offline
Reply With Quote
May 29, 2004, 02:00 PM
 
Here is what I am looking for: The program has been running and all windows have been closed. When you click on the icon, the main window opens up. Nothing is minimized.

Uncle Skeleton: I checked out the documentation on that and it looks like it is what I need. Where would you place that function? Also, do I need to make any connections in IB?
     
Professional Poster
Join Date: Sep 2000
Location: Texas
Status: Offline
Reply With Quote
May 29, 2004, 02:33 PM
 
Ok I have it now running that function. Now I am stuck on trying to open the main window.... I have tried the following:

[[theApplication mainWindow] makeKeyAndOrderFront:nil];
[[theApplication keyWindow] makeKeyAndOrderFront:nil];

They were all tried in the following:

if(flag == NO)
{
//open the mainwindow
}

return;

Suggestions?
     
Professional Poster
Join Date: Sep 2000
Location: Texas
Status: Offline
Reply With Quote
May 29, 2004, 02:45 PM
 
Solution:

I created a connection between the class and the window in IB.

IBOutlet NSWindow *mainWindow;

Then in the above function, I did the following:

[mainWindow makeKeyAndOrderFront:nil];

Now it works fine! Thanks!
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 06:33 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2