• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problem Displaying a Sheet During Drag-and-Drop
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem Displaying a Sheet During Drag-and-Drop


  • Subject: Re: Problem Displaying a Sheet During Drag-and-Drop
  • From: Dominik Pich <email@hidden>
  • Date: Wed, 23 May 2007 01:33:17 +0200

_I_ dont _THINK you can do that.....
the problem is sheets are modal  and so is a drag operation

If someone says otherwise, please enlighten me :)

Regards,
Dominik

On May 23, 2007, at 1:09 AM, David Emme wrote:

I have a single-document app, based on Core Data, which is a database/catalog of images (slides and prints). I am adding support for cataloging image files (jpegs, etc).

As a convenience, I have implemented drag-and-drop so that the user can drop one or several jpeg files onto my window, and I will create a new "record" (Core Data entity) for each file dropped. This is all working.

Now I want to drop a sheet during performDragOperation: processing, to allow the user to set defaults for certain image attributes (where image was taken, etc); these defaults will be set into each of the several newly-created "records". However, I am unable to figure out how to drop the sheet during drag-and-drop processing. Depending on what I've tried, I either hang my app, requiring a Force Quit, or I get an error message and the drag operation is canceled. The error message is:

2007-05-22 15:51:02.996 ImageLib[26826] *** Assertion failure in - [NSApplication _commonBeginModalSessionForWindow:relativeToWindow:modalDelegate:didEn dSelector:contextInfo:], AppKit.subproj/NSApplication.m:3057
2007-05-22 15:51:02.997 ImageLib[26826] *** Canceling drag because exception 'NSInternalInconsistencyException' (reason 'Modal session requires modal window') was raised during a dragging session


My code looks like the following (extraneous details removed):

-(BOOL)performDragOperation:(id <NSDraggingInfo>)sender {
NSManagedObjectContext *moc = [self managedObjectContext];
NSString *aPath = nil;
NSEnumerator *en = [imageFilePathsToImport objectEnumerator];

// Custom initialization here
[self constructModelImageForDnD]; // SHOULD DROP THE SHEET TO GET USER DEFAULTS
if (!modelImage) return NO; // user canceled

while (aPath = [en nextObject]) {
EImage * newImage = [NSEntityDescription insertNewObjectForEntityForName:@"Image" inManagedObjectContext:moc];
[[self document]initializeImage:newImage from:modelImage];
[[NSAppDelegate imageFileImporter] importImageFile:aPath toImage:newImage];
}
[self removeModelImageForDnD];
return YES;
}


- (void)constructModelImageForDnD {
if (!dndSheet) {
[NSBundle loadNibNamed:@"DragNDropSheet" owner:self];
}

// Display the sheet; allow user to specify image attribute defaults.
// [NSApp runModalForWindow:[self window]];
// HERE'S THE PROBLEM SHEET
[NSApp beginSheet:dndSheet modalForWindow:[self window] modalDelegate:self didEndSelector:nil contextInfo:NULL];
}


There are "Continue" and "Cancel" IBAction buttons on the sheet. If "Continue" is clicked, image attribute values will be taken from the sheet and used in Core Data entity construction via the "modelImage" entity. "Cancel" will abort the whole drag operation.

As the code in constructModelImageForDnD stands above, I get the indicated error message and the drag operation is canceled. I've tried various combinations with the [NSApp runModalForWindow... included, but then the app just hangs. Specifying "modalDelegate:nil" instead of "modalDelegate:self" (I saw that somewhere(?)) also gives me the same error message.

How can I successfully drop a sheet during the drag-and-drop operation?

TIA,
-Dave
--
FAILURE IS NOT AN OPTION!
It comes bundled with the software.

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >Problem Displaying a Sheet During Drag-and-Drop (From: David Emme <email@hidden>)

  • Prev by Date: Problem Displaying a Sheet During Drag-and-Drop
  • Next by Date: Re: Encoding infinite loops
  • Previous by thread: Problem Displaying a Sheet During Drag-and-Drop
  • Next by thread: Re: Problem Displaying a Sheet During Drag-and-Drop
  • Index(es):
    • Date
    • Thread