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 > Why does my open panel disappear immediately?

Why does my open panel disappear immediately?
Thread Tools
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status: Offline
Reply With Quote
Oct 27, 2003, 11:15 PM
 
I'm just trying to generate an open panel after a button is pressed. The panel pops up, but then disappears immediately before I can do anything. Here's the code:

Code:
- (void)associatePDFFileWithArticle { NSOpenPanel *panel=[NSOpenPanel openPanel]; [panel beginSheetForDirectory:nil file:nil types:[NSImage imageFileTypes] modalForWindow:nil modalDelegate:self didEndSelector: @selector(openPanelDidEnd:returnCode:contextInfo:) contextInfo:nil]; } -(void)openPanelDidEnd:(NSOpenPanel *) openPanel returnCode:(int)returnCode contextInfo:(void *)x { NSString *path; NSLog(@"panedidend"); if (returnCode==NSOKButton) { path=[openPanel filename]; } }
thanks,
kman
     
Senior User
Join Date: Nov 2001
Location: State of Denial
Status: Offline
Reply With Quote
Oct 28, 2003, 01:37 AM
 
I think it may be because you're attempting to run it as a sheet, but passing nil as the modalForWindow: paremeter. Maybe you want to use runModalForDirectory:file:types: ?
[Wevah setPostCount:[Wevah postCount] + 1];
     
kman42  (op)
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status: Offline
Reply With Quote
Oct 28, 2003, 08:38 AM
 
Originally posted by Wevah:
I think it may be because you're attempting to run it as a sheet, but passing nil as the modalForWindow: paremeter. Maybe you want to use runModalForDirectory:file:types: ?
I'll give that a try. I snagged the above method from Hillegass' book where he says that passing nil will cause the panel to be standalone (which it is for a split second), otherwise it will slide down as a sheet.

kman
     
   
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 07:19 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