[apps/math_toolbox] Handle const char * when selecting a leaf.

Else, there would be a problem with sequence_toolbox, where not all
toolbox leaves are message trees.

Change-Id: Ib4968aad37f6a835b1ea4d77efac2ae1bd19c7ce
This commit is contained in:
Léa Saviot
2018-01-19 16:24:05 +01:00
parent 2cb8956665
commit f3e6b10410
6 changed files with 31 additions and 30 deletions

View File

@@ -47,7 +47,7 @@ App::App(Container * container, Snapshot * snapshot) :
// insertText() also moves the cursor. We need to re-move it to the
// position we want (which is after the first parenthesis or before the
// first point).
int deltaCursorLocation = - textArea->cursorLocation() + previousCursorLocation + Shared::ToolboxHelpers::CursorIndexInCommand(text);
int deltaCursorLocation = - textArea->cursorLocation() + previousCursorLocation + Shared::ToolboxHelpers::CursorIndexInCommandText(text);
// WARNING: This is a dirty and only works because the cursor location we
// want is always on the first line of the text we insert. Because of the
// auto indentation, it would be difficult to compute the wanted cursor
@@ -59,7 +59,7 @@ App::App(Container * container, Snapshot * snapshot) :
if (!textField->isEditing()) {
textField->setEditing(true);
}
int newCursorLocation = textField->cursorLocation() + Shared::ToolboxHelpers::CursorIndexInCommand(text);
int newCursorLocation = textField->cursorLocation() + Shared::ToolboxHelpers::CursorIndexInCommandText(text);
if (textField->insertTextAtLocation(text, textField->cursorLocation())) {
textField->setCursorLocation(newCursorLocation);
}}),