Local vs non-local drags and -ignoreModifierKeysWhileDragging
Local vs non-local drags and -ignoreModifierKeysWhileDragging
- Subject: Local vs non-local drags and -ignoreModifierKeysWhileDragging
- From: Kyle Sluder <email@hidden>
- Date: Fri, 29 Apr 2011 11:14:34 -0700
I'm working on an application that uses a master-detail view. The
detail area includes a text area for freeform notes (each item can
have multiple notes). The note area parses references to other items
(a URL of the form "item:///item-number") and turns them into
clickable links.
Right now, dragging a row from the master table view puts an NSString
on the pasteboard containing a URL reference to the item. This is
suitable for dropping in the note area or in other applications.
I also want to provide alternate methods of dragging: a Cmd-Drag to
the note area would create a new note containing some boilerplate "See
also" text, followed by a URL reference to the item (rather than
attempting to insert the reference into whatever note text it was
dropped on). An option-drag would move all the source item's notes
into the destination item, and delete the source item (a merge
operation). The same behavior would occur for an option-drag solely
within the master table view.
These meanings conflict with the system-standard notions of dragging
modifier flags, described in the documentation for -[<NSDraggingInfo>
draggingSourceOperationMask]. So I need to return NO from
-ignoreModifierKeysWhileDragging to prevent the system from ANDing the
wrong operation constants with what I return from
-dragSourceOperationMaskForLocal:. (Yes, there was a somewhat lengthy
discussion about whether it was appropriate to redefine the meaning of
modifier keys for this drag operation.)
But I don't necessarily want to alter the semantics of a non-local
drag. So overriding -ignoreModifierKeysWhileDragging to always return
NO seems incorrect. Quite frankly I'm puzzled why this is a method on
the source object in the first place, since it's the destination
that's going to have to determine what operation to select based on
the current event's modifier flags when -draggingUpdated: is called.
It would be okay if -ignoreModifierKeysWhileDragging had an isLocal
argument, so I could return YES or NO. Right now I'm stuck stuffing
the argument to -dragSourceOperationMaskForLocal: into an ivar, and
reading that ivar from -ignoreModifierKeysWhileDragging. But this
feels fairly hackish, and I don't see a guarantee that a call to
-ignoreModifierKeysWhileDragging will always be proceeded by a call to
-dragSourceOperationMaskForLocal:.
So, if you wanted to redefine the meaning of modifier flags only for
local drags, would you feel satisfied capturing the argument passed to
-dragSourceOperationMaskForLocal: and returning that value from
-ignoreModifierKeysWhileDragging? Do you agree with me that
-ignoreModifierKeysWhileDragging should either be removed, or also get
an isLocal argument?
Any input (including historical context about the relevant drag API)
is appreciated.
Thanks,
--Kyle Sluder
_______________________________________________
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