diff --git a/src/rviz/properties/color_editor.cpp b/src/rviz/properties/color_editor.cpp index 1b3ab4e7f6..54b05433fe 100644 --- a/src/rviz/properties/color_editor.cpp +++ b/src/rviz/properties/color_editor.cpp @@ -78,13 +78,18 @@ void ColorEditor::resizeEvent(QResizeEvent* event) void ColorEditor::parseText() { - QColor new_color = parseColor(text()); + const QString t = text(); + QColor new_color = parseColor(t); if (new_color.isValid()) { color_ = new_color; if (property_) { + auto pos = cursorPosition(); property_->setColor(new_color); + // setColor() normalizes the text display and thus looses cursor pos + setText(t); // thus: restore original, unnormalized text + setCursorPosition(pos); // as well as cursor position } } }