Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom NSView Fill Paints Over Bottom Bar
    primarykey
    data
    text
    <p>I have a window which has a custom <code>NSView</code> and has a bottom bar with controls on it, one of which is an <code>NSColorWheel</code>.</p> <p>For simplicity sake the Window is 332px high, with the custom NSView being 300px high and the bottom bar being 32px high.</p> <p>The bottom bar is created as part of my <code>awakeFromNib</code> when the app loads the window using the following code:</p> <pre><code>[[self window] setAutorecalculatesContentBorderThickness:YES forEdge:NSMinYEdge]; [[self window] setContentBorderThickness: 32.0 forEdge: NSMinYEdge]; </code></pre> <p>In my custom <code>NSView</code> class I fill the rectangle with color. Everything works fine when the app loads using the following in my <code>NSView</code> class:</p> <pre><code>- (void)drawRect:(NSRect)dirtyRect { dirtyRect = [self bounds]; NSColor * mNewColor = [NSColor blackColor]; [mNewColor set]; [NSBezierPath fillRect:dirtyRect]; } </code></pre> <p>However, if I subsequently call a method that changes the color of the custom <code>NSView</code> when a color wheel in the bottom bar is changed, the bottom bar gets overwritten with the color. The following code illustrates this method (this code is in the custom <code>NSView</code> class:</p> <pre><code>- (void)changeBackgroundColor:(NSNotification *)notification { NSLog(@"Changed background color"); NSRect mRect = [self bounds]; NSColor * mNewColor = [theColorWell color]; [mNewColor set]; [NSBezierPath fillRect:mRect]; [self setNeedsDisplay:YES]; } </code></pre> <p>Resizing the window instantly corrects the problem, but obviously I don't want the user to have to resize the window for an obvious bug!</p> <p>What I don't understand is why my <code>bounds</code> appear to be mapping to the parent window and not the custom <code>NSView</code> when I call <code>setNeedsDisplay</code> and yet the bound correctly adjust when I resize the window using the mouse (even if just by 1 pixel).</p> <p>Do I somehow need to account for the bottom bar on the redraw?</p> <p>Any and all help much appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload