Advice on restricting/monitoring character input in NSTextView
Advice on restricting/monitoring character input in NSTextView
- Subject: Advice on restricting/monitoring character input in NSTextView
- From: Scott Lehman <email@hidden>
- Date: Mon, 6 Feb 2006 16:28:14 -0800 (PST)
I'm looking to prevent some characters and sequences
(such as tabs and consecuive spaces for starters) from
being entered into my NSTextView. After some
searching of the list archives, I know to steer clear
of overriding keyDown: and have the following
strategy:
For input from the keyboard:
-Use the delegate
shouldChangeTextInRange(s):replacementString(s)
methods (Can I safely assume this is called one
character at a time for keyboard input?)
-Use delegate textView:doCommandBySelector: methods
for intercepting special keys (i.e. the insertTab:
command, though the previous method can easily handle
tabs)
For input from the pasteboard:
-Create a NSTextView subclass to override the paste
text methods, including some text filtering before
inserting any text
I think that will work, I would much prefer to have
the filtering/processing centralized in one place.
Are there other strategies to consider that let me
catch all text input, be it key presses, the
pasteboard, or any other source I'm unaware of?
I found the NSTextStorage delegate method
textStorageWillProcessEditing: which appears to be a
good hook to clean up text input. Any issues with
using that?
Is there anything else earlier in the text input chain
of command? Is there a safe way to change input in a
custom text storage class'
replaceCharactersInRange:withString: implementation?
Thanks,
Scott
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
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