unexpected NSTextViewDelegate behavior
unexpected NSTextViewDelegate behavior
- Subject: unexpected NSTextViewDelegate behavior
- From: David Young <email@hidden>
- Date: Thu, 21 Jul 2016 10:33:01 -0500
- Mail-followup-to: email@hidden
Sometimes my implementation of NSTextViewDelegate method
textView:shouldChangeTextInRanges:replacementStrings: is called with
different arguments than I expect. Maybe I have overlooked some
way to get the desired behavior?
Here is an example of the behavior. I select a character, the 'w'
in the sentence below---I will use [] to indicate selections:
All [w]ork and no play makes Jack a dull boy.
Next, I Command-select another character, the 'b':
All [w]ork and no play makes Jack a dull [b]oy.
Then I tap the Delete key. I expect for the AppKit to call my
textView:shouldChangeTextInRanges:replacementStrings: method once with
ranges [rangeOfW, rangeOfB] and replacementStrings ["", ""]. Instead,
textView:shouldChangeTextInRanges:replacementStrings: is called twice,
once with [rangeOfW] and [""], and a second time with [rangeOfB] and
[""].
For my purposes, it is desirable for shouldChangeTextInRanges: to
see all of the ranges affected by a single editing command, such as
deleteBackward(), at once. Is there some way to select the behavior
that I expect?
Dave
--
David Young //\ Trestle Technology Consulting
(217) 721-9981 Urbana, IL http://trestle.tech/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden