• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Question on NSTextView And Syntax Highlighting...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Question on NSTextView And Syntax Highlighting... (From: email@hidden)

  • Prev by Date: know if an application need all the screen.
  • Next by Date: Re: Distinct action messages from matrix of NSButtonCells
  • Previous by thread: Question on NSTextView And Syntax Highlighting...
  • Next by thread: NSEvent Question
  • Index(es):
    • Date
    • Thread