• 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: Dragging Rect
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dragging Rect


  • Subject: Re: Dragging Rect
  • From: Lorenzo <email@hidden>
  • Date: Wed, 11 Jun 2003 19:09:14 +0200

Hi John,
thank you, I understood. In facts when I removed the call
[super drawRect:]
the obects have been redrawn the same...

But, don't you think adding a view just for the dragging rect is a heavy
task?


Best Regards
--
Lorenzo
email: email@hidden

> From: John Haney <email@hidden>
> Date: Wed, 11 Jun 2003 09:59:25 -0700 (PDT)
> To: Lorenzo <email@hidden>, email@hidden
> Subject: Re: Dragging Rect
>
> Lorenzo,
>
> Calling [super drawRect:] doesn't draw the subviews.
> That is managed at a different level.
>
> Instead, you may want to have a separate view for just
> the dragging rect which sits on top of all the other
> objects the user is selecting. That way, this view
> will indeed be called last, since it's on top.
>
>
> - John Haney
> http://www.johnhaney.com/
>
> --- Lorenzo <email@hidden> wrote:
>> Hi,
>> I would like to draw a typical rectangle while I am
>> selecting objects in my
>> view by dragging the mouse.
>> I did that, but the rectangle has been drawn under
>> the objects, instead I
>> would like to draw the rectangle *over* the objects.
>> I did this in my subclassed NSView class.
>>
>> In the drawRect method, I told the view to draw the
>> objects first using
>> [super drawRect:rect], then the rectangle using
>> NSFrameRect(dragRect).
>> So, where is my error?
>>
>>
>> /////////////////////////////////////
>> - (void)mouseDown:(NSEvent*)theEvent
>> {
>> initialLocation = [self convertPoint:[theEvent
>> locationInWindow]
>> fromView:nil];
>> }
>>
>>
>> /////////////////////////////////////
>> - (void)mouseDragged:(NSEvent *)theEvent
>> {
>> isDragging = YES;
>>
>> currentLocation = [self convertPoint:[theEvent
>> locationInWindow]
>> fromView:nil];
>> dragRect = MYRectFromPoints(initialLocation,
>> currentLocation);
>> [self setNeedsDisplayInRect:dragRect];
>> }
>>
>>
>> /////////////////////////////////////
>> - (void)mouseUp:(NSEvent *)theEvent
>> {
>> isDragging = NO;
>> [self setNeedsDisplayInRect:[self frame]];
>> }
>>
>>
>> /////////////////////////////////////
>> -(void)drawRect:(NSRect)rect
>> {
>> [backgroundColor set];
>> NSRectFill([self bounds]);
>> [super drawRect:rect];
>>
>> if(isDragging){
>> [[NSColor orangeColor] set];
>> NSFrameRect(dragRect);
>> }
>> }
>>
>>
>> Best Regards
>> --
>> Lorenzo
>> email: email@hidden
>> _______________________________________________
>> 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.
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
> http://calendar.yahoo.com
_______________________________________________
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.

  • Follow-Ups:
    • Re: Dragging Rect
      • From: John Haney <email@hidden>
References: 
 >Re: Dragging Rect (From: John Haney <email@hidden>)

  • Prev by Date: Re: access relational database in cocoa program
  • Next by Date: Putting color wells in a table.
  • Previous by thread: Re: Dragging Rect
  • Next by thread: Re: Dragging Rect
  • Index(es):
    • Date
    • Thread