Re: Where did I just type that character?
Re: Where did I just type that character?
- Subject: Re: Where did I just type that character?
- From: Douglas Davidson <email@hidden>
- Date: Tue, 29 Aug 2006 15:33:43 -0700
On Aug 26, 2006, at 3:19 AM, Mike R. Manzano wrote:
I have an NSTextStorage whose contents are being displayed in
several NSTextViews. After typing a character into one of the text
views, how can I programmatically detect which text view it is that
I typed into?
I noticed that the first responder status of the text views does
not change if I type past the boundaries of the first text view
into a second one (which I am adding in response to
layoutManager:managerdidCompleteLayoutForTextContainer:atEnd:). I'd
like to use the aforementioned detection to automatically set the
second text view as the first responder.
My text views hilite in a special way when they become first
responder, and I'd like the hilite to transition between text views
as I type between them.
The text views associated with a single layout manager often act in
concert, because they really represent only different portions of the
same text. In this case, what you are asking for may not be well-
defined--for example, the insertion point may show up in one text
view, but the text you type may end up in another. Possibly what you
really want is to look for changes in the selection, and to determine
which text view to highlight based on that. There is a text view
delegate method that you can use to be notified of changes in the
selection, and you can use layout manager methods to determine which
container (and hence text view) you are interested in. Bear in mind,
though, that when there is a non-zero-length selection, it may lie
partly in one text view and partly in another, and you will have to
decide what to do in that case.
Douglas Davidson
_______________________________________________
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