NSTextInput problems
NSTextInput problems
- Subject: NSTextInput problems
- From: Eyal Redler <email@hidden>
- Date: Tue, 28 May 2002 01:26:40 +0200
Hi All,
I'm having trouble with NSTextInput protocol.
I've scanned every resource for answers on this. I hope someone here can
help me.
I have a custom view I want to allow text input in. I cannot get accented
characters with keyDown+insertText.
Since my view is not based or connected with the regular text system I
must implement this but the documentation is a bit weak on this...
Questions:
1. How does the "Marked Text" relate to the selection? I saw no way of
reporting where my selection is and it seems that the caller thinks that
the insertion is always at index 1. I suspect that I'm not intializing or
updating something.
2. The docs say that hasMarkedText is not called from the input manager,
but in my app it is being called(?) (caller is NSInputContext) Should I
base my answer on whether the range is empty or not or should I just say
"YES" if I support the concept?
3. insertText. What should I do to the marked text range?
My implementation goes something like this:
- (NSAttributedString *) attributedSubstringFromRange:(NSRange)theRange {
return [textModel attributedSubstringFromRange:theRange];
}
- (unsigned int)characterIndexForPoint:(NSPoint)thePoint {
return -1;// To do
}
- (long) conversationIdentifier{
return (long)textModel;
}
- (NSRect) firstRectForCharacterRange:(NSRange)theRange {
NSRect aRect; // to do
return aRect;
}
- (BOOL) hasMarkedText {
if (_inputManagerRange.length>0)
return YES;
else
return NO;
}
- (void)insertText:(NSString *)aString {
[textModel userEnteredText:aString];
}
- (NSRange) markedRange {
if ([self hasMarkedText])
return _inputManagerRange;
else
return NSMakeRange(NSNotFound,0);
}
- (NSRange) selectedRange {
return [textModel getSelectedRange];
}
- (void) setMarkedText:(id)aString selectedRange:(NSRange)selRange {
[textModel replaceTextInRange:aString range:selRange];
_inputManagerRange=selRange;
}
- (void) unmarkText {
_inputManagerRange.location=NSNotFound;
_inputManagerRange.length=0;
}
- (NSArray*) validAttributesForMarkedText {
return [NSArray array];
}
I'm really stuck on this...
Thanks,
Eyal
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.