Rulers in shared text views
Rulers in shared text views
- Subject: Rulers in shared text views
- From: Bill Cheeseman <email@hidden>
- Date: Sat, 27 Jul 2002 11:18:33 -0400
I would appreciate advice about the following problem using rulers with
shared text views.
I have implemented three text views, each with its own separate text
container and text layout, but all sharing a single text storage. This is
all according to the documentation about creating multiple views of a single
text storage object and Doug Davidson's talk at WWDC 2002, to my best
understanding.
Everything works as it should, except this: When I apply formatting in one
of the text views using a ruler, the formatting action does not appear in
one of the other text views until I move the mouse. If I use the Format menu
to trigger the same formatting action, the formatting takes effect instantly
in all text views. This suggests a problem with rulers in shared text views,
or a problem in my understanding of their use.
Here's a more precise description of the problem: Two of the text views are
in panes of an ancillary split view window, and the third is in a text view
in a drawer in the primary document window. When I use a ruler in one of the
split window panes, the format in the drawer text view doesn't change until
I move the mouse, although the format in the other pane of the split window
changes immediately. When I do it the other direction, using a ruler in the
drawer's text view, the format changes immediately in both panes of the
split window.
It strikes me that this is incorrect behavior, and that the Cocoa text
system should handle this correctly without my having to write any
additional code.
My implementation is extremely simple. All three text views are created in
Interface Builder, which therefore takes care of setting up all the
components of the text system for each text view. At run time, the drawer's
window is created first, when the document is opened. Then the user clicks a
button to open the split window. The split window's controller is created
lazily at this time, and it is initialized with a reference to the
NSTextStorage object associated with the drawer's text view. In the split
window controller's awakeFromNib method, the NSLayoutManager associated with
each of the text views in the split window is sent a message to
replaceTextStorage: with the drawer's NSTextStorage object. The
replaceTextStorage: method is supposed to clean up the text views' component
networks appropriately, resulting in a single shared NSTextStorage object
with the three separate NSLayoutManager-NSTextContainer-NSTextView chains.
The formatting I'm applying with the ruler is text alignment (left, center,
right) and line spacing. Like everything to do with the ruler, I understand
these are paragraph styles, that they are stored in the NSTextStorage object
as attributes of the mutable attributed string, and that they should be
updated immediately in all text views that share the same text storage.
I'm using Jaguar 6C106, if this is relevant.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
Croquet Club of Vermont -
http://members.valley.net/croquetvermont
_______________________________________________
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.