Button doesn't respond in a modal sheet created from window NIB
Button doesn't respond in a modal sheet created from window NIB
- Subject: Button doesn't respond in a modal sheet created from window NIB
- From: Keith Blount <email@hidden>
- Date: Tue, 23 Nov 2004 11:09:18 -0800 (PST)
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Hello,
I have created a modal sheet using
beginSheet:modalForWindow:... which creates the sheet
using a window I have created in a separate NIB file.
I call this from within my outline view's drag'n'drop
delegate method
outlineView:acceptDrop:item:childIndex:index after
checking for the NSFilenamesPboardType. Basically, if
someone drags from Finder to my outline view, the
files are copied into the project. While this is
happening, I want to show a sheet with a progress bar
and a button to stop the process. The progress bar and
sheet work fine, but the button does not respond. And
yes, it is definitely wired up correctly in IB. Here
are the relevant parts of my code:
- (BOOL)outlineView:(NSOutlineView*)ov acceptDrop:(id
<NSDraggingInfo>)info item:(id)targetItem
childIndex:(int)index
{
int i, n;
// Get the pasteboard
NSPasteboard *pboard = [info draggingPasteboard];
if ([pboard availableTypeFromArray:[NSArray
arrayWithObject
NSFilenamesPboardType]] != nil)
{
NSArray *fileList = [pboard
propertyListForType:NSFilenamesPboardType];
// Show progress sheet:
[fileImportProgressText
setStringValue:@"Importing..."]; // text field
[NSApp beginSheet:fileImportProgressSheet
modalForWindow:[verticalSplitView window] // main
window
modalDelegate:nil
didEndSelector:nil
contextInfo:NULL];
cancelOperation = NO; // global BOOL
[fileImportProgressBar
setUsesThreadedAnimation:YES];
[fileImportProgressBar startAnimation:self];
// Go through files
for (i=0; i<[fileList count]; i++)
{
if (cancelOperation == YES)
{
cancelOperation = NO;
break;
}
// Show which file we are importing in the import
sheet
NSString *importText = [NSString
stringWithFormat:@"Importing %@...",[fileList
objectAtIndex:i]];
[fileImportProgressText setStringValue:importText];
[fileImportProgressText display]; // Force display
of text
// CODE HERE JUST COPIES ALL THE RELEVANT FILES TO
PROJECT FOLDER
}
[ov reloadData];
// Now get rid of the progress sheet
[fileImportProgressBar stopAnimation:self];
[fileImportProgressSheet orderOut:self];
[NSApp endSheet:fileImportProgressSheet
returnCode:1];
}
return YES;
}
And this is the action to which the button in the
sheet is connected:
- (IBAction)cancelCurrentOperation:(id)sender
{
cancelOperation = YES;
}
But like I say, this never even gets called. If you
try to press the button, nothing happens - it doesn't
flash blue or respond in any way, there's not even a
beep. I thought this might be because it is modal, and
that it might be suffering in the same way my progress
bar was until I realised that I had to use
setUsesThreadedAnimation for that, but I have another
sheet created from a window in a NIB with a button
that works fine. The only difference I can see is that
the other sheet I use is created from an action
connected to a menu, and there's not a for... loop
bang in the middle of it. Could this be the problem?
If somebody could tell me what I'm doing wrong, I
would be very grateful.
Many thanks,
Keith
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden