• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: draw and ... draw, not drawing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: draw and ... draw, not drawing


  • Subject: Re: draw and ... draw, not drawing
  • From: "Shawn Erickson" <email@hidden>
  • Date: Fri, 24 Feb 2006 12:28:16 -0800

On 2/24/06, Michael Hanna <email@hidden> wrote:
> I have a drag operation from one view(an nsmatrix subclass) to an
> nsview subclass. I have a draggedImage too. When I release the mouse,
> concludeDragOperation is being called fine. I would like to take the
> draggedImage and draw it in the NSView subclass. I lock the focus on
> the object that is getting the draw operation and then I call
> drawAtPoint, right? This seems not to do anything, not even an error.
> XCode 2.2, 10.4.5, 10.3.9 target.
>
> Mike
>
> - (void)concludeDragOperation:(id <NSDraggingInfo>)sender {
>
>          NSLog(@"concludeDragOperation [sender draggingLocation] %f %
> f", [sender draggingLocation].x, [sender draggingLocation].y);
>          NSImage* dropImage = [sender draggedImage];
>          NSPoint drawLocation = [self convertPoint:[sender
> draggingLocation] fromView:nil];
>
>          [self lockFocus];
>          [dropImage drawAtPoint:drawLocation fromRect:NSZeroRect
> operation:NSCompositeSourceOver fraction:1.0];
>          [self unlockFocus];
>          [self setNeedsDisplay:YES];
>
> }

You likely are drawing the image ok in the above (not a good way to
try to do it) but very soon afterwards you are redrawing your entire
NSView subclass which will clobber what you did draw.

What you need to do is store what you want to draw someplace in the
NSView, mark you view needing to be redrawn and then in your drawRect
method draw the stored image.

-Shawn
 _______________________________________________
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

  • Follow-Ups:
    • Re: draw and ... draw, not drawing
      • From: Scott Anguish <email@hidden>
References: 
 >draw and ... draw, not drawing (From: Michael Hanna <email@hidden>)

  • Prev by Date: draw and ... draw, not drawing
  • Next by Date: Send key commands to other window...
  • Previous by thread: draw and ... draw, not drawing
  • Next by thread: Re: draw and ... draw, not drawing
  • Index(es):
    • Date
    • Thread