Re: Refreshing subviews
Re: Refreshing subviews
- Subject: Re: Refreshing subviews
- From: Lorenzo <email@hidden>
- Date: Thu, 06 May 2004 11:41:37 +0200
Hi Fritz,
my very best, it worked. The "hitTest" it's a very clever solution.
I added a fine fix, that is placing the frame at (int) origins. In facts, if
it is placed at float origin points (e.g. 10.4, 20.7), the blue borders
appear unfocused. Thanky you again. You are a clever guy!
Best Regards
--
Lorenzo
email: email@hidden
>
From: Fritz Anderson <email@hidden>
>
Date: Wed, 05 May 2004 17:06:14 -0500
>
To: Lorenzo <email@hidden>
>
Subject: Re: Refreshing subviews
>
>
Note the hitTest: method. By returning a nil result, clicks are never
>
reported in the adorner view -- they go through to the other subviews.
>
>
-- F
>
>
>
On 5 May 2004, at 5:00 PM, Lorenzo wrote:
>
>
> Hello Fritz,
>
> thanks, I know this solution. I used it for cropping images and
>
> drawing the
>
> selected square. But in my case now I cannot use it because when I
>
> select
>
> the main view I should still be able to click and select the subviews
>
> it
>
> contains. So if I put a view over my main view, I cannot select and
>
> click on
>
> it subviews anymore. Do you know ho to do?
>
>
>
>
>
> Best Regards
>
> --
>
> Lorenzo
>
> email: email@hidden
>
>
>
>> From: Fritz Anderson <email@hidden>
>
>> Date: Wed, 05 May 2004 12:56:49 -0500
>
>> To: Lorenzo <email@hidden>
>
>> Cc: email@hidden
>
>> Subject: Re: Refreshing subviews
>
>>
>
>> The problem is that all of a view's subviews draw over it, and there
>
>> is
>
>> no hook for drawing over them. What I'd try is an "adorner" subview,
>
>> to
>
>> go last in the list, that would draw the highlight frame. Something
>
>> like this:
>
>>
>
>> #define FRAME_INSET 1.0
>
>> #define FRAME_WIDTH (2.0 * FRAME_INSET)
>
>>
>
>> @interface FrameAdorner : NSView { }
>
>> - (id) initWithParent: (NSView *) inParent;
>
>> @end
>
>>
>
>> @implementation FrameAdorner
>
>>
>
>> - (id) initWithParent: (NSView *) inParent
>
>> {
>
>> NSRect parentFrame = [inParent frame];
>
>> parentFrame.origin = NSZeroPoint;
>
>>
>
>> if (self = [self initWithFrame: parentFrame]) {
>
>> [inParent addSubview: self];
>
>> [self setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
>
>> }
>
>>
>
>> return self;
>
>> }
>
>>
>
>> - (NSView *) hitTest: (NSPoint) aPoint { return nil; }
>
>> - (BOOL) isOpaque { return NO; }
>
>>
>
>> - (void) drawRect: (NSRect) aRect
>
>> {
>
>> NSRect bounds = [self bounds];
>
>> [[NSColor blueColor] set];
>
>> bounds = NSInsetRect(bounds, FRAME_INSET, FRAME_INSET);
>
>> NSFrameRectWithWidth(bounds, FRAME_WIDTH);
>
>> }
>
>> @end
>
>>
>
>> In the main view's awakeFromNib method, do
>
>> adorner = [[FrameAdorner alloc] initWithParent: self];
>
>> [adorner release];
>
>> (In this simple implementation, there's no need to keep a reference to
>
>> the adorner view, and the addSubview: message retains the adorner
>
>> until
>
>> the main view is released.)
>
>>
>
>> This version doesn't turn the frame on and off, so you'd have to add
>
>> state to both the adorner and the main view to take care of that.
>
>>
>
>> -- F
>
>>
>
>> On 5 May 2004, at 9:48 AM, Lorenzo wrote:
>
>>
>
>>> Hi,
>
>>> I put some subviews within a main view.
>
>>> When the user clicks on one of the subviews or the main view, I
>
>>> select
>
>>> the
>
>>> mainview and show a blue frame along its borders. The problem is that
>
>>> when
>
>>> the subview is large as the main view I don't see the blue border
>
>>> anymore.
>
>>>
>
>> --
>
>> Fritz Anderson
>
>> Consulting Programmer
>
>> http://resume.manoverboard.org/
_______________________________________________
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.