• 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: ScalingScrollView with Sketch [workaround]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ScalingScrollView with Sketch [workaround]


  • Subject: Re: ScalingScrollView with Sketch [workaround]
  • From: Jeff Argast <email@hidden>
  • Date: Thu, 26 Feb 2004 09:24:01 -0700

Eric-

I have seen the same text drawing on top of text behavior that you
describe. It's either a bug or you and I are doing the same wrong
thing! :)

I came up with a different workaround that also works for rotated text
views in a scaled view. Give the following a whirl (I have done this
in my own application rather than doing it in the modified sketch
example, but I believe the theory is the same)

Do not override isRotatedOrScaleFromBase nor drawRect. Instead,
override setNeedsDisplayInRect

- (void) setNeedsDisplayInRect:(NSRect)nsRect
{
// Call ours first to do whatever it needs to do
[super setNeedsDisplayInRect:nsRect];

// Convert our rect into superview rect coordinates
NSRect superRect = [self convertRect:nsRect toView:[self superview]];

// Tell super view it needs to display
[[self superview] setNeedsDisplayInRect:superRect];
}

Presumably we should override setNeedsDisplay as well. And it might
not hurt to outset the superrect by 1 in all directions, although so
far I haven't seen any drawing artifacts that would indicate I need the
slop.

Is your goal to ultimately create a text object similar to those in
OmniGraffle/Keynote?

Jeff

> FROM: Eric Forget
> DATE: 2004-02-26 11:47
>
> 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
_______________________________________________
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.


  • Follow-Ups:
    • Re: ScalingScrollView with Sketch [workaround]
      • From: Eric Forget <email@hidden>
    • Re: ScalingScrollView with Sketch [workaround]
      • From: Eric Forget <email@hidden>
  • Prev by Date: Re: Problems with Distributed Objects
  • Next by Date: The best method to print an NSString with HTML content
  • Previous by thread: Re: Setting windows attrubutes to use applicationShouldTerminateAfterLastWindowClosed:
  • Next by thread: Re: ScalingScrollView with Sketch [workaround]
  • Index(es):
    • Date
    • Thread