• 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: limit text input in NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: limit text input in NSTextView


  • Subject: Re: limit text input in NSTextView
  • From: Arthur Clemens <email@hidden>
  • Date: Tue, 17 Sep 2002 21:18:01 +0200

> No, if you're not going to use a formatter, you can use the NSTextView
> delegate method
>
> - (BOOL)textView:(NSTextView *)textView
> shouldChangeTextInRange:(NSRange)affectedCharRange
> replacementString:(NSString *)replacementString;
>

It seems that shouldChangeTextInRange: is useful for intercepting
character input; for delete and arrow keys navigation I must still rely
on keyDown.

Let me sketch my problem:
I have a NSTextView with a number of 'keywords' that I want to be
immutable - you cannot delete them or click inside them. Around the
keywords (and between the keywords) is text that allows all the normal
operations: insert, delete, paste, etcetera.
When the user does a text operation, for instance 'delete', I must know
the cursor position relative to the keywords.
So for instance when I have the cursor directly to the right side of a
keyword, I must intercept the delete command. If the cursor is placed
elsewhere, I will allow the delete command.

As
- (BOOL)shouldChangeTextInRange:(NSRange)affectedCharRange
replacementString:(NSString *)replacementString
gives me a string but no keycode, I cannot infer what key is being
pressed, when this is the delete key or an arrow key.

So I now assume I have to do some checking in both
shouldChangeTextInRange: and in keyDown:.


Arthur Clemens
_______________________________________________
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.

  • Follow-Ups:
    • Re: limit text input in NSTextView
      • From: Douglas Davidson <email@hidden>
References: 
 >Re: limit text input in NSTextView (From: Douglas Davidson <email@hidden>)

  • Prev by Date: Re: DB-Engine
  • Next by Date: Re: limit text input in NSTextView
  • Previous by thread: Re: limit text input in NSTextView
  • Next by thread: Re: limit text input in NSTextView
  • Index(es):
    • Date
    • Thread