Why won't my TextView contents become a string?
Why won't my TextView contents become a string?
- Subject: Why won't my TextView contents become a string?
- From: Ryan Hale <email@hidden>
- Date: Tue, 6 Aug 2002 22:40:26 -0500
I've looked over my code but can't seem to find the error. "boldText" is
the contents of an NSTextView. I want the contents to be placed in a
string so that I can add the string to "theText" and insert it into my
main document.
What happens is IB gives me a strange error. I'm [linking] an image.
code:
<File attached: OHHorizontalRule.pdf>
- (IBAction)addBoldText
<File attached: frown.png>id)sender
{
NSMutableString *boldText;
NSString *theText;
NSRange theRange;
NSRange rangeToSelect;
boldText = [theTextView string];
// build the string, trivial
theText = [NSString stringWithFormat:@"%@", boldText];
// Here we force the text view to become the first responder, so
that the
// selection is visually displayed properly if there is no selection
[[theTextView window] makeFirstResponder:theTextView];
// insert the string that we've built above
[theTextView insertText:theText];
// get the current selected range (which will be right after
// the just inserted text)
theRange=[theTextView selectedRange];
// calculate the range that will contain the text that is contained
within the
// construct that we've just built. Odds are that the user may
want to edit it.
// you may want to modify this so that holding down different
modifier keys will
// provide you with different selection behaviours
rangeToSelect.location=(theRange.location-4)-[boldText length];
rangeToSelect.length=[boldText length];
[theTextView setSelectedRange:rangeToSelect];
// we're done! So we need to return YES
// returnValue=YES;
}
<File attached: 1__#$!@%!#__OHHorizontalRule.pdf>
Image:
http://homepage.mac.com/rhale1/app-error.jpg
PS: This is an HTML Editor. That may be obvious due to the "b" tags.
___________________________
Ryan Hale
email@hidden
Anxiously awaiting Jaguar!
_______________________________________________
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.