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

Error when trying to edit Matrix #13

Open
MFJones21 opened this issue Jun 26, 2017 · 4 comments
Open

Error when trying to edit Matrix #13

MFJones21 opened this issue Jun 26, 2017 · 4 comments

Comments

@MFJones21
Copy link

MFJones21 commented Jun 26, 2017

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.

@cupojoe
Copy link

cupojoe commented Apr 19, 2019

@MFJones21 Did you ever figure this out?

@iosappsdevelopers
Copy link

@MFJones21 @cupojoe : Did you ever figure this out?
@kostub

@cupojoe
Copy link

cupojoe commented Sep 7, 2020

@iosappsdevelopers No, never. I stopped working on this project so never got to having to implement Matrices. I was ready to re-implement this.

@MCChao211
Copy link

@MFJones21 Did you ever figure this out?

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

4 participants