Created
December 4, 2016 23:10
-
-
Save zorgiepoo/b58ba63335bfa559ddbd4f4e028a1fc4 to your computer and use it in GitHub Desktop.
Using https://developer.apple.com/reference/uikit/nstextstoragedelegate/1534375-textstorage?language=objc which is documented to allow changing attributes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I'm not using the passed editRange and delta because I've found them to be quite misleading... | |
// This happens to be a new API (macOS 10.11) so maybe it's not really battle tested or I don't know what I'm doing | |
// Either way I'd like to support older systems so for portability sake it's easier to not use these parameters | |
- (void)textStorage:(NSTextStorage *)textStorage didProcessEditing:(NSTextStorageEditActions)editedMask range:(NSRange)editedRange changeInLength:(NSInteger)__unused delta | |
{ | |
if ((editedMask & NSTextStorageEditedCharacters) != 0) | |
{ | |
//[self updateTextProcessingForTextStorage:textStorage]; | |
//NSLog(@"Edited range: %lu, %lu", editedRange.location, editedRange.length); | |
[textStorage removeAttribute:NSBackgroundColorAttributeName range:NSMakeRange(0, textStorage.length)]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment