Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5953003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:45:45+00:00 2026-05-22T17:45:45+00:00

I’m looking for an explanation of NSWindow’s dragImage method. – (void)dragImage:(NSImage *)image at:(NSPoint)imageLocation offset:(NSSize)pointerOffset

  • 0

I’m looking for an explanation of NSWindow’s dragImage method.

- (void)dragImage:(NSImage *)image at:(NSPoint)imageLocation offset:(NSSize)pointerOffset event:(NSEvent *)event pasteboard:(NSPasteboard *)pasteboard source:(id)sourceObject slideBack:(BOOL)slideBack

Any help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:45:45+00:00Added an answer on May 22, 2026 at 5:45 pm

    The NSView documentation of that method provides a much more detailed explanation, including example code. The only difference between the two methods is the coordinate system that imageLocation is in. Find it at http://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html#//apple_ref/doc/uid/20000014-SW135

    Edit: Here is the sample code from that link, with added comments.

    - (void)mouseDown:(NSEvent *)theEvent {
        // Create an offset for the offset parameter. Since it is ignored, you should just use 0,0.
        NSSize dragOffset = NSMakeSize(0.0, 0.0);
        NSPasteboard *pboard;
    
        // Get the pasteboard used to hold drag-and-drop data
        pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
        // Declare the data type used on the pasteboard. This sample passes a TIFF representation of an image
        [pboard declareTypes:[NSArray arrayWithObject:NSTIFFPboardType]  owner:self];
        // Add the data to the pasteboard.
        [pboard setData:[[self image] TIFFRepresentation] forType:NSTIFFPboardType];
        // Call dragImage:... with:
        // An image representing the object you are dragging. This could be a file's icon or a screenshot of a view, etc.
        [self dragImage:[self image]
        // The starting location of the image in this views coordinates. This should be close to the location of the object you are dragging.
                     at:[self imageLocation]
        // An NSSize structure. This is not used.
                 offset:dragOffset
        // The mousedown event
                  event:theEvent
        // The pasteboard which contains the data
             pasteboard:pboard
        // The object providing the data
                 source:self
        // Whether or not the image should slide to its starting location if the drag isn't completed.
              slideBack:YES];
    
    }
    

    The source object (self in this case) needs to implement the NSDraggingSource protocol. You may also be interested in the NSPasteboard Class Reference.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I would like to count the length of a string with PHP. The string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.