Skip to content

Commit

Permalink
ColorEditor: maintain edited text + cursor pos (#1609)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhaschke authored Apr 8, 2021
1 parent 5a9631d commit 1872e34
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/rviz/properties/color_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down

0 comments on commit 1872e34

Please sign in to comment.