• 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
Changing drag image while modal
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Changing drag image while modal


  • Subject: Changing drag image while modal
  • From: Jonathan Guy <email@hidden>
  • Date: Mon, 11 Feb 2013 11:43:02 +0000

While performing a drag and drop in NSOutlineView at the point where I accept the drop I
want to throw up an NSPopover at the drop point with some options and an accept or decline button to ultimately
accept or refuse the drop. The popover needs to run modal so as to block on the return to accept. So this in short
is what I'm doing:

- (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(NSInteger)index
{
	[popover showRelativeToRect:rect ofView:outlineView preferredEdge:preferredEdge];

	NSWindow *window = popover.contentViewController.view.window;

	NSInteger ret = [NSApp runModalForWindow:window];

	return (ret == 1);
}

This works but the problem is the drag image ends up on top of the popover obscuring some
of the controls. I have tried to remove the drag image by running

	[info enumerateDraggingItemsWithOptions:0
		forView:outlineView
		classes:[NSArray arrayWithObject:[NSURL class]]
		searchOptions:nil
		usingBlock:^(NSDraggingItem *draggingItem, NSInteger idx, BOOL *stop) {
			// tried this
			[draggingItem setDraggingFrame:NSZeroRect contents:nil];
			// and this
			draggingItem.imageComponentsProvider = nil;
			// but neither work
		}];

just before showing the popover but this has no effect.

I also tried subclassing NSOutlineView and doing

- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
	[sender enumerateDraggingItemsWithOptions:0
		forView:self
		classes:[NSArray arrayWithObject:[NSURL class]]
		searchOptions:nil
		usingBlock:^(NSDraggingItem *draggingItem, NSInteger idx, BOOL *stop) {
			draggingItem.imageComponentsProvider = nil;
		}];

	return [super performDragOperation:sender];;
}

but no joy here either.

Any help on doing this would be greatly appreciated
I'm using the newer multi pasteboard item api

- (id <NSPasteboardWriting>)outlineView:(NSOutlineView *)outlineView pasteboardWriterForItem:(id)item

Thanks
Jonathan
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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

  • Follow-Ups:
    • Re: Changing drag image while modal
      • From: Keary Suska <email@hidden>
  • Prev by Date: How to create OODBSM's database engine in Objective-C & cocoa?
  • Next by Date: Re: NSComboBox and Multiple Selection
  • Previous by thread: How to create OODBSM's database engine in Objective-C & cocoa?
  • Next by thread: Re: Changing drag image while modal
  • Index(es):
    • Date
    • Thread