Re: NSTextView setRulerVisible: weirdness
Re: NSTextView setRulerVisible: weirdness
- Subject: Re: NSTextView setRulerVisible: weirdness
- From: Keith Blount <email@hidden>
- Date: Sun, 12 Jun 2005 15:16:39 -0700 (PDT)
Many thanks for the reply.
I have come to the conclusion that the ruler's
accessory view is supposed to act like that, because
it can change depending on what view is the first
responder (for instance, if two views share the ruler
view). I don't know why there is such a delay when the
view is set to initialFirstResponder, though - it
seems that the only way is to set it in code using
NSWindow's makeFirstResponder:.
In my case I finally tracked down the main cause of my
problem, though - it had nothing to do with the ruler,
the ruler somehow just brought it to my attention. I
was trying to account for scaling in my view like
this:
scale = [self frame].size.height / [self
bounds].size.height;
In certain instances, scale was coming out as "nan"
(not a number), though, so I guess I had a zero
divided by zero issue. Changing this to:
scale = 1.0;
if ([self frame].size.height)
scale = [self frame].size.height / [self
bounds].size.height;
seems to have fixed things nicely.
Thanks again,
Keith
--- Todd Ransom <email@hidden> wrote:
> For what it's worth, I see similar behavior with my
> app under Tiger.
> The ruler's accessory view will not show unless the
> user first clicks
> in the text view. Setting the text view to be first
> responder on
> window load fixed the behavior in one instance but
> not in another.
>
> Todd Ransom
> Return Self Software
> http://returnself.com
>
>
>
> On Jun 12, 2005, at 11:05 AM, Keith Blount wrote:
>
> > Hello,
> >
> > I seem to have fixed this problem, though I'm not
> > quite sure why. If I call [[textView window]
> > makeFirstResponder:textView] before calling
> > -setRulerVisible:, everything works fine, whether
> I
> > call -setRulerVisible before or after loading the
> text
> > and notes, and there is no delay in showing the
> ruler.
> > I'm not quite sure why I have to do this to
> prevent
> > such odd behaviour - especially seeing as my
> custom
> > view is set to initialFirstResponder in IB, and my
> > custom view just passes on first responder status
> to
> > the text view in -becomeFirstResponder - but at
> least
> > things seem to be working without a problem now.
> >
> > Thanks anyway,
> > Keith
> >
> > --- ORIGINAL MESSAGE ---
> >
> > FROM : Keith Blount
> > DATE : Sun Jun 12 11:10:19 2005
> >
> > Hello,
> >
> > I am seeing some strange effects when calling
> > setRulerVisible:YES on an NSTextView. My text view
> is
> > contained inside a container view that places a
> margin
> > view (NSView subclass) on the left of the text
> view.
> > The container view works out all resizing so that
> it
> > is big enough to contain both the margin and the
> text
> > view, and it is the container view that is set as
> the
> > document view of the text view.
> >
> > The margin view just displays notes that are
> > associated with the text. The notes are stored as
> a
> > custom attribute in the text storage
> > (KBNoteAttributeName associated with a string).
> >
> > In my document, in windowControllerDidLoadNib:, I
> > first load the text using readRTFDFromFile: and
> then I
> > set up the notes from an array, cycling through
> the
> > array and applying note attributes to the text.
> >
> > If I call setRulerVisible:YES on the text view
> before
> > I load the text and apply the notes, everything
> works
> > fine, except that the ruler doesn't show any tabs
> or
> > the alignment buttons until all the notes have
> been
> > applied, so there's a two second pause.
> >
> > However, if I call setRulerVisible:YES on the text
> > view *after* loading the text and applying the
> notes,
> > my view loads with the ruler visible, but it is
> not
> > sized or drawn properly. The text and margin view
> are
> > visible, but their container view hasn't done any
> > resizing or drawing, as though its subviews have
> > loaded but it hasn't done anything else...
> >
> > A workaround that works is this:
> >
> > [textView setRulerVisible:YES];
> > [textView setRulerVisible:NO];
> >
> > [self loadTextAndNotes];
> >
> > [textView setRulerVisible:YES];
> >
> > By quickly setting the ruler visible and hiding at
> > again before loading text and notes, then doing
> the
> > loading, then setting the ruler visible again,
> > everything seems to load fine - the ruler is
> visible
> > with no pause at the same time as the text and
> notes.
> > This seems a very strange thing to have to do,
> though.
> >
> > Does anybody have any idea what is going on here?
> >
> > Many thanks for any help in advance,
> > Keith
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam
> protection around
> > http://mail.yahoo.com
> > _______________________________________________
> > 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
> >
>
>
__________________________________
Discover Yahoo!
Get on-the-go sports scores, stock quotes, news and more. Check it out!
http://discover.yahoo.com/mobile.html
_______________________________________________
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