Re: ScalingScrollView with Sketch [workaround]
Re: ScalingScrollView with Sketch [workaround]
- Subject: Re: ScalingScrollView with Sketch [workaround]
- From: Eric Forget <email@hidden>
- Date: Thu, 26 Feb 2004 05:47:21 -0500
Hi,
Finally, I may have found a workaround. However I feel this is a bug in
Cocoa: maybe someone else may confirm it?
To resolve the problem you have to subclass NSTextView and override 2
methods:
@implementation MyTextView
- (BOOL)isRotatedOrScaledFromBase
{
// This prevents the spacing between glyphs from being laid out badly
return NO;
}
- (void)drawRect:(NSRect)rect
{
// This prevents drawing over itself multiple times creating bold
// glitches while selecting the text
[[self superview] displayRect:rect];
// Just let NSTextView do its job!
[super drawRect:rect];
}
@end
Overriding drawRect: is necessary only if you setDrawsBackground to NO, as
it is the case with the Sketch sample.
It looks like NSTextView is using heavily lockFocus/drawRect instead of
display or displayRect, preventing ancestors to be drawn up to the first
opaque view.
Eric
>
In the application I'm writing, I'm using Sketch derived code. I'm having
>
some difficulties with scaling, specially with the SKTTextArea "model". To
>
reproduce the problems you need to add the ScalingScrollView class from
>
TextEdit sample and replace the NSScrollView by ScalingScrollView in the
>
DrawWindow.nib (it takes less than 2 minutes doing it!).
>
>
The problems are:
>
>
1) As long as you do not scale, everything is fine
>
>
2) If you scale up (or down) and back to 100% all the text drawing are
>
glitchy when editing the text. If don't see them, just change the font.
>
>
I've been able to reduce the problem as this:
>
>
[self setBoundsSize:[self bounds].size];
>
>
The last line seems to create an unrecoverable error, even when bounds.size
>
is equal to frame.size. I'm pretty sure there is a way to get around that.
>
Keynote, OmniGraffle do not have those glitches...
___________________________________________________________________
Eric Forget Cafederic
email@hidden <
http://www.cafederic.com/>
Fingerprint <86D5 38F5 E1FD 5D9C 71C3 BAA3 797E 70A4 6210 C684>
_______________________________________________
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.