Re: Drag to Nowhere and Disappearing Smoke
Re: Drag to Nowhere and Disappearing Smoke
- Subject: Re: Drag to Nowhere and Disappearing Smoke
- From: Robert Cerny <email@hidden>
- Date: Tue, 6 Sep 2005 12:02:53 +0200
Hi,
subclass the NSTableView and implement following method
- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)flag
{
return NSDragOperationDelete;
}
- (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint
operation:(NSDragOperation)operation
{
if ( !NSMouseInRect([[self window] convertScreenToBase:aPoint],
[self bounds], NO) ) //is outside views bounds
{
NSShowAnimationEffect(NSAnimationEffectDisappearingItemDefault,
aPoint, NSZeroSize, nil, nil, nil);
[[self dataSource] deleteIndexes:[self selectedRowIndexes]];
}
}
HTH
Robert
On 6.9.2005, at 11:50, Philip Dow wrote:
NSShowAnimationEffect() displays a system animation at a given
point in screen coordinates. The effect is used to indicate that an
item has been removed from a list without actually deleting the
underlying data. An example is dragging an item out of the far left
list in a finder window. As you drag, the cursor changes to show
the disappearing smoke, and when you let go the system runs the
smoke animation. That let's you know you're removing the item from
the list without deleting the item itself.
I would like to implement this effect to remove an item from a
table without deleting it. I can call the cocoa function no
problems. What I'm running up against is catching the drag to
nowhere. On the one hand, I'd like to know a drag is going on so
that I can change the cursor, on the other I need to know when the
drag is finished and, by the criterion of a normal drag, rejected,
so that I can show the effect and operate on my data. I figure if
the finder can do this, I can get pretty close.
I could catch mouseUp: in my window controller, but then how would
I know a drag is involved? Or I could implement drag in my window
and handle drops out of my tables in this special way. In either
case, I cannot accomplish what the finder can. When dragging out of
that far left list, you can drag to anywhere, window or not, to
remove the item.
Has anyone had any experience trying something like this, or does
anyone know of any online articles or examples?
-Phil
http:phildow.net
_______________________________________________
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
_______________________________________________
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