Custom ruler view for NSTextView?
Custom ruler view for NSTextView?
- Subject: Custom ruler view for NSTextView?
- From: Keith Blount <email@hidden>
- Date: Thu, 14 Apr 2005 06:46:55 -0700 (PDT)
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Hello,
Does anyone know of any good tutorials for or just
have some experience with/advice about subclassing
NSRulerView for use with an NSTextView?
I have a text view that has various other elements
above it, so screen space is at a premium, but I want
a ruler. I therefore want a narrower ruler (more like
the ruler you see in Word or Nisus), with custom
marker images, in which the user can ctrl-click to
choose ruler marker types rather than using a drag
well.
I have gone through the docs, tried overriding the
ruler view methods in NSTextView and in
NSLayoutManager, and subclassing NSRulerView, but
still I cannot get the results I want.
These are some of my main issues:
1) It seems that the only way to get rid of the
accessory view is to subclass NSLayoutManager and
return nil for rulerAccessoryViewForTextView:...
2) Adjusting the thickness of my NSRulerView subclass
seems to have no effect. And if I try to call
drawHashMarksAndLabelsInRect: with a smaller rect, the
drawing just gets clipped rather than drawing within
the specified rect.
3) If I override rulerView:handleMouseDown: in my text
view subclass to add my markers with custom images,
the image is returned to the default one as soon as
the user lets go of the mouse button upon adding a new
marker.
4) I can override the default images using
NSLayoutManager's rulerMarkersForTextView: and
enumerating through the markers and calling setImage:,
but this seems an odd way to have to do it. Moreover,
I cannot check what sort of NSTextTabStop the marker
represents. Despite the docs saying that a text view's
ruler marker's represented object is an NSTextTab, the
represented I am getting seems to be a plain
NSString...
Unfortunately, I can't find anything in the docs, in
any of my books, or on the web about how to subclass
NSRulerView to give it a custom look for an
NSTextView, and yet I would think a lot of people have
done this. I would be very grateful if anyone has any
tips or can point me in the direction of something I
might be missing.
Many thanks in advance,
Keith
__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/
_______________________________________________
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