Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two bugs about input Chinese #19

Open
snaill opened this issue Dec 3, 2012 · 0 comments
Open

Two bugs about input Chinese #19

snaill opened this issue Dec 3, 2012 · 0 comments

Comments

@snaill
Copy link

snaill commented Dec 3, 2012

Thanks for your great jobs, when I use EGOTextView, I found two bugs:

  1. crash when I input chinese
  2. after I set FontSize, EGOTextView show default fontSize in first character

I try fixed it, hope useful:

  • (void)setMarkedText:(NSString *)markedText selectedRange:(NSRange)selectedRange {

    NSRange selectedNSRange = self.selectedRange;
    NSRange markedTextRange = self.markedRange;

    NSAttributedString *newString = [[NSAttributedString alloc] initWithString:markedText attributes:self.defaultAttributes];

    if (markedTextRange.location != NSNotFound) {
    if (!markedText)
    markedText = @"";

    [_mutableAttributedString replaceCharactersInRange:markedTextRange withAttributedString:newString]; / fixed for bug 2
    markedTextRange.length = markedText.length;
    

    } else if (selectedNSRange.length > 0) {

    [_mutableAttributedString replaceCharactersInRange:selectedNSRange withAttributedString:newString]; // fixed for bug 2
    markedTextRange.location = selectedNSRange.location;
    markedTextRange.length = markedText.length;
    

    } else {

    [_mutableAttributedString insertAttributedString:newString atIndex:selectedNSRange.location];
    markedTextRange.location = selectedNSRange.location;
    markedTextRange.length = markedText.length;
    

    }

    [newString release];
    selectedNSRange = NSMakeRange(selectedRange.location + markedTextRange.location, selectedRange.length);

    self.attributedString = _mutableAttributedString; // fixed for bug1
    self.markedRange = markedTextRange;
    self.selectedRange = selectedNSRange;

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant