Re: Detecting option key down/up during drag
Re: Detecting option key down/up during drag
- Subject: Re: Detecting option key down/up during drag
- From: Keith Renz <email@hidden>
- Date: Mon, 17 Nov 2003 14:00:05 -0500
Dan,
I've searched the mamasam archives and haven't found a definitive
answer. How can I detect the option key down/up during a drag like
the Finder? I've implemented dragging in a table view, but I want to
be able to option-drag to make a copy (vs. move) and be able to
change my mind in the middle of a drag. I can detect the option key
immediately before the drag starts, but that doesn't help during the
drag.
There are two ways (off the top of my head):
In Cocoa, if your "dragging" is implemented using mouseDragged:
(rather than an event loop within your own mouseDown:), then you
should be able to implement flagsChanged:(NSEvent *) method to keep
track of the current modifier state.
I'm using NSTableViews dragging methods, and it appears I want to check
for the option key down in tableView:validateDrop:proposedRow:(int)row
proposedDropOperation: because that's where the NSDragOperation is set
(which sets the cursor, etc.). But this method only gets invoked when
the drag position has changed. If you don't move the mouse to a new
drag position, this method never gets invoked. Also, I don't receive
any events (keyDown, flagsChanged, etc.) during the drag operation. In
the Finder, holding the mouse still and pressing the option key
instantly changes to drag operation from move to copy (and the cursor).
So, I'm trying to figure out how to imitate this behavior.
In Carbon, you can use GetKeys() and interpret the resulting map.
Left as an exercise to the reader... :-)
Sure, but where can I use GetKeys() during the drag operation? It will
work in the above mentioned table view drag method, but only when I'm
moving the mouse to a new drag position. I guess I'm trying to figure
out how to hook into the drag operation's event loop.
Thanks,
Keith
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.