Weird bug with selection in Textview with custom textcontainer
Weird bug with selection in Textview with custom textcontainer
- Subject: Weird bug with selection in Textview with custom textcontainer
- From: <email@hidden>
- Date: Sat, 25 Mar 2006 10:10:31 +0100
- Thread-topic: Weird bug with selection in Textview with custom textcontainer
Hi all,
I ran in this weird bug and you guys are my last resort..
For a new DNA analysis program I subclassed Koen van der Drift's excellent NSTextView linenumbering variant and modified the textcontainer such that it automagically adds spaces between every 10th character. I did this by overriding in NSTextContainer (see below).
This works beautifully except for this single strange behaviour where text is not selected if
A) there are more than 10 characters (is one column) present
B there's not more than 1 line of text.
Trying to select the first 10 characters is not possible and a reverse selection started at for instance char 20 back will stop always at character 11. If the textview does not contain more than 9 characters selection goes fine in the first column! So does it when the textview contains more than one line of text!
In other words, I cannot select the 10 characters in the first column for some reason.
I've illustrated the problem in this screenshot: http://www.mekentosj.com/temporary/textview_problem.jpg
Any solution / clue where to start looking would be enormously appreciated. Last bug standing before a release...
Cheers,
Alex
- (NSRect)lineFragmentRectForProposedRect:(NSRect)proposedRect
sweepDirection:(NSLineSweepDirection)sweepDirection
movementDirection:(NSLineMovementDirection)movementDirection
remainingRect:(NSRect *)remainingRect
{
// create space for the linenumber margin
if(proposedRect.origin.x <= 0.0)
proposedRect.origin.x = kLEFT_MARGIN_WIDTH;
// set the width of a column of text
proposedRect.size.width = columnWidth;
// make sure we nicely break after a full column
if (proposedRect.origin.x + 2 * columnWidth - 20.0 >= [self containerSize].width) *remainingRect = NSZeroRect;
else {
remainingRect->origin.x = proposedRect.origin.x + columnWidth - 10.0;
remainingRect->origin.y = proposedRect.origin.y;
remainingRect->size.width = [self containerSize].width - proposedRect.origin.x + columnWidth - 10.0;
remainingRect->size.height = proposedRect.size.height;
}
return proposedRect;
}
*********************************************************
** Alexander Griekspoor **
*********************************************************
The Netherlands Cancer Institute
Department of Tumorbiology (H4)
Plesmanlaan 121, 1066 CX, Amsterdam
Tel: + 31 20 - 512 2023
Fax: + 31 20 - 512 2029
AIM: email@hidden
E-mail: email@hidden
Web: http://www.mekentosj.com
4Peaks - For Peaks, Four Peaks.
2004 Winner of the Apple Design Awards
Best Mac OS X Student Product
http://www.mekentosj.com/4peaks
*********************************************************
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden