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

ColorEditor: maintain edited text + cursor pos #1609

Merged
merged 1 commit into from
Apr 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe put this line together withe line 81 is better to read(just a suggestion).
It a nice fix to the issue.

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