• 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: Equivelent to drawRect: for drawing after sub views are drawn
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Equivelent to drawRect: for drawing after sub views are drawn


  • Subject: Re: Equivelent to drawRect: for drawing after sub views are drawn
  • From: George Lawrence Storm <email@hidden>
  • Date: Fri, 8 Oct 2004 02:38:36 -0700

On Oct 7, 2004, at 11:58 PM, John C. Randolph wrote:

I need to perform the equivalent to NSView's drawRect:, however I need
it to be called AFTER its sub views are drawn.

Is there a method I can override for such a purpose?

I need to draw a transparent overlay & some guidelines which will
overlap some of those sub views.

I think you'll be better served by using an overlay window. That may also give you better performance as well.
Check out the following example:
<http://developer.apple.com/samplecode/FunkyOverlayWindow/ FunkyOverlayWindow.html>

Let me just chime in here, and point out that the technique demonstrated in the sample that Mr. Sharp has pointed out is supported, and that clobbering private methods is not. In fact, situations like this are precisely why we provided the -addChildWindow:ordered: method on NSWindow.

Mr. Storm's approach has a very high probability of failure on future releases.

Two points:

First, part of this experiment was to prove its viability so I could submit it as a (pre-tested) Feature Request, Bug Reporter Problem ID: 383050.

Second, if the method is removed in future versions of Cocoa it will simply not be called and my overlays would not be drawn. Yes it would be a bug in my program but not a catastrophic one. I consider this a reasonable risk while waiting for a reply to my feature request. I still have a few months before my public release and will consider other alternatives when I have more time to devote to them.

Yes FunkyOverlayWindow does offer an alternative, but certainly not in less then the six lines of code I ended up with. Plus this is much lower overhead as it does not add the overhead of another NSWindow with the added calls between my view and this secondary window and it keeps my overlay drawing tightly encapsulated in my mainView.

- (void)_recursiveDisplayAllDirtyWithLockFocus:(BOOL)fp8 visRect:(struct _NSRect)fp12
{
[super _recursiveDisplayAllDirtyWithLockFocus:fp8 visRect:fp12];
[self lockFocus];
[self drawPostRect];
[self unlockFocus];
}

plus adding [myScrollView setDrawsBackground:NO]; to one of my awakeFromNib's.

-----

My #1 RANT: If Apple would open the Cocoa source like we had in PowerPlant & MacApp it would make the job of following the code flow much easier and I would have likely found a more elegant solution. The lack of open source in Cocoa coupled with the erratic documentation makes trouble shooting & design much more difficult, time consuming and makes fully understanding the frameworks impossible. I am sure that if we could trace through the code you would have a lot fewer people scratching their heads over how to adopt bindings and probably reduce the number of questions on this list by more than half.

-----

George Lawrence Storm
Macintosh Applications Development
Snohomish (Seattle), Washington
E-mail: <email@hidden>

_______________________________________________
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: Equivelent to drawRect: for drawing after sub views are drawn
      • From: "R. Scott Thompson" <email@hidden>
    • Re: Equivelent to drawRect: for drawing after sub views are drawn
      • From: Shawn Erickson <email@hidden>
References: 
 >Re: Equivelent to drawRect: for drawing after sub views are drawn (From: "John C. Randolph" <email@hidden>)

  • Prev by Date: Has anyone any experience with NSTableView and NSArrayController ?
  • Next by Date: NSImageView PICTRepresentation?
  • Previous by thread: Re: Equivelent to drawRect: for drawing after sub views are drawn
  • Next by thread: Re: Equivelent to drawRect: for drawing after sub views are drawn
  • Index(es):
    • Date
    • Thread