CD/Bindings and NSTextView
CD/Bindings and NSTextView
- Subject: CD/Bindings and NSTextView
- From: Adam Knight <email@hidden>
- Date: Mon, 26 Dec 2005 02:58:42 -0600
I have a CD/Bindings-based app with a two-pane interface. The top is
a table listing entries and the bottom an NSTextView. I'm trying to
remember the selected text when a user changes entries. I have the
get/set of selection ranges down, and I know when to save the
selection, but restore is proving a pain in the posterior.
Method #1: NSTextField notifications
If I use textDidBeginEditing/textDidEndEditing to set/get the
selection I only get. It won't set the selection because editing in
the text field only "begins" when you make a change, and once you've
made a change your selection is irrelevant (note, also, "selection"
is insertion point position).
Method #2: KVO on the NSArrayController's selectionIndexes property
If I use this method (using method #1 for set, since it works) I find
that when I get the notification the text field still has the old
item in it, so any changes to selection I make are made on the "old"
entry and give out of bounds errors and cause things to forever go
south until the document is closed.
Method #3: KVO on the NSTextField's textStorage
Never triggers. No reason it should, I suppose.
Method #99: Add set/get to every since piece of code that can change
the selection.
Ungh. Please, no.
Is there a better way to do this? I need to be able to set the
selection of a text view in a split view right after bindings has
changed the content of the text view, but everything I do happens too
soon. I even tried to use perform/delay in method #2 but the
selection data I had was of the previous entry because the change
hadn't happened yet.
Adam Knight
I ♥ my
If you're not going to stop and appreciate the scenery, you're not
going to
enjoy Myst. The same thing applies on the Mac as well. -- Rand Miller
_______________________________________________
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