Re: Overlapping focus rings, clipping?
Re: Overlapping focus rings, clipping?
- Subject: Re: Overlapping focus rings, clipping?
- From: Manfred Lippert <email@hidden>
- Date: Mon, 23 Jun 2003 16:10:41 +0200
My control has the following shape
O====O
and is drawn in three parts by one cell; the middle bar and the two
end circles.
The problem is that when the system draws the focus ring, the ring
from each piece bleeds over the other pieces.
I had the same problem in LittleSecrets. The solution: You have to draw
your control in an "offscreen image" (NSImage) and then draw it with
one drawing command. Then the system draws only one focus ring around
the entire control.
If you draw your control with more than one drawing call, then you get
focus rings around all drawn parts of your control what normally looks
ugly.
Here is the code how I am drawing the Toolbar Search Field in
LittleSecrets (<
http://www.mani.de/>):
- (void)drawRect:(NSRect)rect {
NSRect srcRect = {{0, 0}, {32, 21}};
NSRect bounds = [self bounds];
NSImage *offscreen = [[NSImage alloc] initWithSize:bounds.size];
[offscreen lockFocus];
[leftcap compositeToPoint:NSZeroPoint
operation:NSCompositeSourceOver];
[rightcap compositeToPoint:NSMakePoint(bounds.size.width - 10, 0)
operation:NSCompositeSourceOver];
[middle drawInRect:NSMakeRect(9, 0, bounds.size.width - 19,
bounds.size.height)
fromRect:srcRect operation:NSCompositeSourceOver
fraction:1.0];
if (clearEnabled) {
[clear compositeToPoint:NSMakePoint(bounds.size.width - 18, 3)
operation:NSCompositeSourceOver];
}
[offscreen unlockFocus];
NSResponder *resp = [[self window] firstResponder];
[self setKeyboardFocusRingNeedsDisplayInRect:bounds];
if ([[self window] isKeyWindow]
&& [resp isKindOfClass:[NSView class]]
&& [(NSView *)resp isDescendantOf:self]) {
NSSetFocusRingStyle(NSFocusRingAbove);
}
[offscreen compositeToPoint:bounds.origin
operation:NSCompositeSourceOver];
[offscreen release];
}
Hope this helps,
Mani
_______________________________________________
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.