diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp index 79a800bf2..b4c35b156 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp @@ -221,6 +221,7 @@ void GLGizmoMeasure::data_changed() m_selected_features.reset(); m_selection_raycasters.clear(); m_editing_distance = false; + m_is_editing_distance_first_frame = true; } bool GLGizmoMeasure::gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down) @@ -258,6 +259,7 @@ void GLGizmoMeasure::on_set_state() m_curr_point_on_feature_position.reset(); restore_scene_raycasters_state(); m_editing_distance = false; + m_is_editing_distance_first_frame = true; } else { m_mode = EMode::BasicSelection; @@ -904,6 +906,7 @@ void GLGizmoMeasure::render_dimensioning() }; auto action_exit = [this]() { m_editing_distance = false; + m_is_editing_distance_first_frame = true; ImGui::CloseCurrentPopup(); }; auto action_scale = [this, perform_scale, action_exit](double new_value, double old_value) { @@ -916,6 +919,13 @@ void GLGizmoMeasure::render_dimensioning() if (ImGui::InputDouble("##distance", &edit_value, 0.0f, 0.0f, "%.3f")) { } + // trick to auto-select text in the input widgets on 1st frame + if (m_is_editing_distance_first_frame) { + ImGui::SetKeyboardFocusHere(0); + m_is_editing_distance_first_frame = false; + m_imgui->set_requires_extra_frame(); + } + // handle keys input if (ImGui::IsKeyPressedMap(ImGuiKey_Enter) || ImGui::IsKeyPressedMap(ImGuiKey_KeyPadEnter)) action_scale(edit_value, curr_value); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.hpp b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.hpp index bba23fb6b..9db2a73aa 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.hpp @@ -119,6 +119,7 @@ class GLGizmoMeasure : public GLGizmoBase SelectedFeatures m_selected_features; bool m_editing_distance{ false }; + bool m_is_editing_distance_first_frame{ true }; void update_if_needed();