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

Re: Refreshing subviews


  • Subject: Re: Refreshing subviews
  • From: Fritz Anderson <email@hidden>
  • Date: Wed, 5 May 2004 12:56:49 -0500

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.


References: 
 >Refreshing subviews (From: Lorenzo <email@hidden>)

  • Prev by Date: Re: Uninstalling an app
  • Next by Date: Re: Uninstalling an app
  • Previous by thread: Refreshing subviews
  • Next by thread: Re: Refreshing subviews
  • Index(es):
    • Date
    • Thread