Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MrFusion

macrumors 6502a
Original poster
Jun 8, 2005
613
0
West-Europe
I have a subclass of NSResponder that implements the NSTextInputClient protocol.

One of the required functions is this one:
Code:
- (void)insertText:(id)aString replacementRange:(NSRange)replacementRange

In whatever user input I give, I never seem to get a valid replacementRange.
Code:
NSLog(@"%@",NSStringFromRange(replacementRange));
Does anyone know under which circumstances a valid range is supposed to be given?
My code works since I just use the selectedRange (also a required function), but I want to make sure I don't miss anything here.

The "TextInputView" sample code implements this function as well, but overrides the replacementRange (in most cases?).

Your insight into this function is appreciated!
 
Last edited:
Post some actual output from the NSLog.

1. Describe what you expected to happen.
2. Describe what actually happened.
 
Post some actual output from the NSLog.

1. Describe what you expected to happen.
2. Describe what actually happened.

I type in any letter -> I get {9223372036854775807, 0} -> I expect something like {4,0} (no selection) or {4,6} (with text selected). (0,4 and 6 are random examples.)
Likewise, TextInputView gets a {very large number,0} as input.
 
I type in any letter -> I get {9223372036854775807, 0} -> I expect something like {4,0} (no selection) or {4,6} (with text selected). (0,4 and 6 are random examples.)
Likewise, TextInputView gets a {very large number,0} as input.

NSTextInputClient protocol reference:
http://developer.apple.com/library/...e.html#//apple_ref/occ/intf/NSTextInputClient

Find the selectedRange method and read what it says is the range when there's no selection. Then look up what NSNotFound is. Maybe even print it out in your code.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.