I'm working on a custom control (a token field), and apparently I've messed with the field editor somehow. When I (as user) click on my control, but not in the focused NSTextView which is the field editor, and then type a character, a message is sent to the field editor telling it to replace text in the range {0, NSUIntegerMax} with the character that I typed. (I see this by debugging into -[NSTextView(NSSharing) shouldChangeTextInRange:replacementString:].) An range exception is raised because the field editor contains an empty string at this time.
I suppose I could fix this by using a custom field editor and overriding that method, but I want the root cause. Has anyone ever seen behavior like this? As you can see from the edited call stack below, it all happens in Cocoa methods. The NSTextView in lines 8-10 is indeed the field editor. Thanks, Jerry Krinock An uncaught exception was raised *** -[NSBigMutableString substringWithRange:]: Range or index out of bounds 0 CoreFoundation __raiseError + 231 1 libobjc.A.dylib objc_exception_throw + 155 2 CoreFoundation +[NSException raise:format:arguments:] + 137 3 CoreFoundation +[NSException raise:format:] + 57 4 Foundation -[NSString substringWithRange:] + 111 5 AppKit -[NSTextStorage(NSUndo) _undoRedoAttributedSubstringFromRange:] + 171 6 AppKit -[NSUndoTyping initWithAffectedRange:layoutManager:undoManager:replacementRange:] + 181 7 AppKit -[NSTextViewSharedData coalesceInTextView:affectedRange:replacementRange:] + 440 8 AppKit -[NSTextView(NSSharing) shouldChangeTextInRanges:replacementStrings:] + 1779 9 AppKit -[NSTextView(NSSharing) shouldChangeTextInRange:replacementString:] + 123 10 AppKit -[NSTextView insertText:replacementRange:] + 498 11 AppKit -[NSTextInputContext insertText:replacementRange:] + 430 12 AppKit -[NSTextInputContext handleTSMEvent:] + 2654 13 AppKit _NSTSMEventHandler + 214 14 HIToolbox _Z22_InvokeEventHandlerUPPP25OpaqueEventHandlerCallRefP14OpaqueEventRefPvPFlS0_S2_S3_E + 36 15 HIToolbox _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 1602 16 HIToolbox _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 482 17 HIToolbox SendEventToEventTarget + 76 18 HIToolbox SendTSMEvent + 74 19 HIToolbox SendUnicodeTextAEToUnicodeDoc + 753 20 HIToolbox TSMKeyEvent + 1007 21 HIToolbox TSMProcessRawKeyEvent + 2795 22 AppKit -[NSTextInputContext handleEvent:] + 1257 23 AppKit -[NSView interpretKeyEvents:] + 220 24 AppKit -[NSTextView keyDown:] + 676 25 AppKit -[NSWindow sendEvent:] + 10891 26 AppKit -[NSApplication sendEvent:] + 4788 27 AppKit -[NSApplication run] + 1007 28 AppKit NSApplicationMain + 1054 29 TestApp main + 245 30 TestApp start + 53 _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com