Re: Question on NSTextView And Syntax Highlighting...
Re: Question on NSTextView And Syntax Highlighting...
- Subject: Re: Question on NSTextView And Syntax Highlighting...
- From: Douglas Davidson <email@hidden>
- Date: Wed, 3 Oct 2001 09:44:21 -0700
On Tuesday, October 2, 2001, at 08:33 PM, email@hidden wrote:
how do I tell NSTextView that:
1.) Let me know when a user has hit the space bar.
2.)On doing so, tell me what the last word he typed was.
The textview's delegate will receive the following:
- (BOOL)textView:(NSTextView *)textView
shouldChangeTextInRange:(NSRange)affectedCharRange
replacementString:(NSString *)replacementString;
- (NSRange)textView:(NSTextView *)textView
willChangeSelectionFromCharacterRange:(NSRange)oldSelectedCharRange
toCharacterRange:(NSRange)newSelectedCharRange;
which should be sufficient for you to determine what is happening as far
as text input and selection changes. To determine the last word, you
can use whatever criteria appeal to you, but to get the same selection
that you would by double-clicking, use
- (NSRange)selectionRangeForProposedRange:(NSRange)proposedCharRange
granularity:(NSSelectionGranularity)granularity;
with NSSelectByWord for the granularity.
Douglas Davidson