MathEditor
MathEditor copied to clipboard
Error when trying to edit Matrix
So I was working on making it possible, so that you could insert an editable Matrix in your editable math label. What I did was inserting this code into MTEditableMathLabel:
`- (void) insertMatrix: (int)rows :(int)columns :(NSString )type { MTMathAtom atom = [MTMathAtomFactory placeholderMatrix:columns :rows :type];
if (_insertionIndex.subIndexType == kMTSubIndexTypeDenominator) {
if (atom.type == kMTMathAtomRelation) {
// pull the insertion index out
_insertionIndex = [[_insertionIndex levelDown] next];
}
}
if (atom) {
if (![self updatePlaceholderIfPresent:atom]) {
// If a placeholder wasn't updated then insert the new element.
[self.mathList insertAtom:atom atListIndex:_insertionIndex];
}
if (atom.type == kMTMathAtomFraction) {
// go to the numerator
_insertionIndex = [_insertionIndex levelUpWithSubIndex:[MTMathListIndex level0Index:0] type:kMTSubIndexTypeNumerator];
} else {
_insertionIndex = _insertionIndex.next;
}
}
self.label.mathList = self.mathList;
[self insertionPointChanged];
if ([self.delegate respondsToSelector:@selector(textModified:)]) {
[self.delegate textModified:self];
}
}`
and this code into MTMathAtomFactory
`+ (MTMathAtom *)placeholderMatrix: (int)width :(int)height :(NSString )envname { NSError error;
NSMutableArray<NSMutableArray<MTMathList*>*>* rows = [[NSMutableArray alloc] initWithCapacity:(NSInteger)height];
for (int y = 0; y < height; y++)
{
NSMutableArray<MTMathList*>* row = [[NSMutableArray alloc] initWithCapacity:(NSInteger)width];
for (int x = 0; x < width; x++)
{
MTMathList* list = [MTMathList new];
[list addAtom:[self placeholder]];
row[x] = list;
}
rows[y] = row;
}
MTMathAtom* table = [MTMathAtomFactory tableWithEnvironment:envname rows:rows error:&error];
return table;
}`
This displays the matrix fine, but when I try to select one of the Values in the matrix I get this error, which I have no idea where it is coming from.
'MTLine type regular inside an MTLine - shouldn't happen'
But the display is exactly the way I want it to be. What is wrong here ? I really need help on this please. Thanks a lot for any help in advance.
@MFJones21 Did you ever figure this out?
@MFJones21 @cupojoe : Did you ever figure this out? @kostub
@iosappsdevelopers No, never. I stopped working on this project so never got to having to implement Matrices. I was ready to re-implement this.
@MFJones21 Did you ever figure this out?