backspace method
Receive a delete (backspace) request, which should delete the right-most component (digit of a constant, variable, operator).
Implementation
@override
DartBlockValueTreeAlgebraicNode? backspace() {
if (rightChild != null) {
rightChild?.backspace();
} else if (operator != null) {
operator = null;
if (parent != null) {
return parent?.replaceChild(this, leftChild);
} else {
leftChild?.parent = null;
return leftChild;
}
} else {
leftChild?.backspace();
}
if (rightChild == null && operator == null) {
if (leftChild == null) {
return parent?.replaceChild(this, leftChild);
} else {
if (parent != null) {
return parent?.replaceChild(this, leftChild);
} else {
return leftChild;
}
}
} else {
/// Return 'this' instead to not have selection change.
return this;
/// Previously returned 'result', which change user selection to the right child
/// when it was previously the parent arithmetic node.
}
}