Drag and Drop Help!

Discussion in 'Mac Programming' started by JHKL, Dec 6, 2007.

  1. JHKL macrumors newbie

    Joined:
    Nov 23, 2007
    Location:
    Toronto, ON
    #1
    Hello everyone,

    I'd like to implement drag and drop functionality for my application, but what I want is for the icon of the dragged item to appear on the screen at the position in which I let go of the mouse. For example, I want to drag a zip file and have the Finder zip icon appear on my subclassed NSView in the position where I released my mouse.

    Now, I figured out how to get the Finder icon image by doing:

    imageToDraw = [[NSWorkspace sharedWorkspace] iconForFile:fileLocationOnDisk];

    But how do I get the co-ordinates of the mouse when the drag ended? I've tried draggedImageLocation in performDragOperation:, I've tried updating a NSPoint with the mouse co-ordinates using mouseDrag:, but not of this seems to work.

    Is there anyone who can assist with this problem? I'd be very grateful.

    Thanks in advance,
    David Gill
     
  2. JHKL thread starter macrumors newbie

    Joined:
    Nov 23, 2007
    Location:
    Toronto, ON
    #2
    LOL, I must need some more caffeine! :)

    Turns out there was no problem at all. I forgot that for testing purposes (to see if the icon would even draw) I put a call to NSMakePoint(0,0) instead of the actual icon's point.

    There actually is no problem. Everything's working now! Sorry to all! :eek:

    Mods please delete this thread. Thanks.
     

Share This Page