Re: Dragging Rect
Re: Dragging Rect
- Subject: Re: Dragging Rect
- From: Lorenzo <email@hidden>
- Date: Thu, 12 Jun 2003 13:40:33 +0200
Hi Marco,
I already did that. I put a new NSView "MYDragRect" inside my main view
"MYView", then I set its frame accordlying to the mouse position during the
drag.
I overrided the drawRect method of "MYDragRect", and... voil`!
It works beatifully. Even with a transparent fill rect color. Very fine!
It appears like a very professional application.
Thank you.
Just to let the others know:
- (void)drawRect:(NSRect)theRect
{
[fillColor set];
NSRectFillUsingOperation(theRect, NSCompositeSourceOver);
[strokeColor set];
NSFrameRect(theRect);
}
where
fillColor = [[NSColor blueColor] colorWithAlphaComponent:0.2]
strokeColor = [NSColor selectedControlColor];
Best Regards
--
Lorenzo
email: email@hidden
>
From: Marco Binder <email@hidden>
>
Date: Thu, 12 Jun 2003 11:08:25 +0200
>
To: Lorenzo <email@hidden>
>
Cc: email@hidden, "John C. Randolph" <email@hidden>
>
Subject: Re: FW: Dragging Rect
>
>
Oh, ok. In this case (that you have separate subviews), it appears
>
conceivable, that they draw ontop of your view (subviews should draw
>
ontop of the superview, shouldnt they?!). For such a setting, I guess
>
my approach were to add a separate view for the selection, too. Have a
>
look into - (void)addSubview:(NSView *)aView
>
positioned:(NSWindowOrderingMode)place relativeTo:(NSView *)otherView
>
of NSView to place your mySelectionView ontop of the other subviews. In
>
mySelectionView, you can just override the drawRect: method to frame
>
the passed rect. The just set the frame of this selection view accoring
>
to your mousedragged coordinates and call setNeedsDisplay. Would that
>
work? Just a thought...
>
>
Marco
>
>
>
Am Mittwoch, 11.06.03, um 22:59 Uhr (Europe/Berlin) schrieb Lorenzo:
>
>
> Hi,
>
> thank you for your suggestion.
>
> I downloaded the CroppedImage sample but it works inside a subclass of
>
> an
>
> NSView, so it works properly when redrawing the dragging rectangle
>
> over the
>
> NSView.
>
>
>
> In my case I subclassed an NSView as "MYView".
>
> Inside MYView I added some objects like NSImageView. Yes, they are
>
> subviews
>
> of MYView that I added with [self addSubview:theImageBox];
>
>
>
> Now I would like to select the NSImageView objects by dragging, but the
>
> dragging rectangle appears under the objects, and I would like to see
>
> it
>
> drawn *over* the objects.
>
>
>
> I copied part of the CroppedImage sample into my application, but I
>
> got the
>
> same result. The rectangle is still under the objects...
>
> I can send you the code I used.
>
>
>
>
>
> Best Regards
>
> --
>
> Lorenzo
>
> email: email@hidden
>
>
>
>> From: "John C. Randolph" <email@hidden>
>
>> Date: Wed, 11 Jun 2003 11:28:32 -0700
>
>> To: Lorenzo <email@hidden>
>
>> Cc: email@hidden
>
>> Subject: Re: Dragging Rect
>
>>
>
>> There's a sample that shows one way to draw a few different styles of
>
>> selection markers. See:
>
>>
>
>> http://developer.apple.com/samplecode/Sample_Code/Cocoa/
>
>> Cropped_Image.htm
>
>>
>
>> On Wednesday, June 11, 2003, at 07:06 AM, Lorenzo 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.
>
>>
>
>> It's not clear what you mean by 'objects' here. Are you referring to
>
>> subviews, or things that your custom view draws in its own graphics
>
>> context?
>
>>
>
>> -jcr
>
>>
>
>> John C. Randolph <email@hidden> (408) 974-8819
>
>> Sr. Cocoa Software Engineer,
>
>> Apple Worldwide Developer Relations
>
>> http://developer.apple.com/cocoa/index.html
>
>>
>
>
>
> ------ End of Forwarded Message
>
> _______________________________________________
>
> 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.
>
>
>
>
>
--
>
|\ /| email@hidden http://www.marco-binder.de
>
| \/ | Telefon: 07531 / 94 19 94 Fax: 07531 / 94 19 92
>
| |ARCO Snail-Mail: Banater Str. 3 - 78467 Konstanz
>
BINDER _____________________________________________________
_______________________________________________
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.