@@ -120,8 +120,10 @@ static bool SliderScalar3D(char const* pLabel, float* pValueX, float* pValueY, f
120120 bool bModified = false ;
121121 bool hovered;
122122 bool held;
123- bool pressed = ImGui::ButtonBehavior (oZDragRect, ImGui::GetID (" ##HandleZ" ), &hovered, &held);
124- if (hovered && held)
123+ ImGuiID iHandleID = ImGui::GetID (" ##HandleZ" );
124+ ImGui::KeepAliveID (iHandleID);
125+ bool pressed = ImGui::ButtonBehavior (oZDragRect, iHandleID, &hovered, &held);
126+ if (held)
125127 {
126128 if (DistToSegmentSqr (vMousePos, vDragStart, vDragEnd) < 100 .0f ) // 100 is arbitrary threshold
127129 {
@@ -141,8 +143,10 @@ static bool SliderScalar3D(char const* pLabel, float* pValueX, float* pValueY, f
141143 ImRect const oXYDrag ((vRectEnd - vRectStart) * fScaleZ + vRectStart,
142144 (vRectEnd - vRectStart) * fScaleZ + vRectStart + ImVec2 (2 .0f * fX3 , 2 .0f * fY3 ));
143145 // if (ImGui::IsMouseHoveringRect(oXYDrag.Min - vSecurity, oXYDrag.Max + vSecurity) && ImGui::IsMouseDown(ImGuiMouseButton_Left))
144- pressed = ImGui::ButtonBehavior (oXYDrag, ImGui::GetID (" ##Zone" ), &hovered, &held);
145- if (hovered && held)
146+ iHandleID = ImGui::GetID (" ##Zone" );
147+ ImGui::KeepAliveID (iHandleID);
148+ pressed = ImGui::ButtonBehavior (oXYDrag, iHandleID, &hovered, &held);
149+ if (held)
146150 {
147151 ImVec2 const vLocalPos = ImGui::GetMousePos () - oXYDrag.Min ;
148152
@@ -220,8 +224,10 @@ static bool SliderScalar3D(char const* pLabel, float* pValueX, float* pValueY, f
220224
221225 // if (ImGui::IsMouseHoveringRect(vHandlePosX - ImVec2(fHandleRadius, fHandleRadius) - vSecurity, vHandlePosX + ImVec2(fHandleRadius, fHandleRadius) + vSecurity) &&
222226 // ImGui::IsMouseDown(ImGuiMouseButton_Left))
223- pressed = ImGui::ButtonBehavior (handle_x_bb, ImGui::GetID (" ##HandleX" ), &hovered, &held);
224- if (hovered && held)
227+ iHandleID = ImGui::GetID (" ##HandleX" );
228+ ImGui::KeepAliveID (iHandleID);
229+ pressed = ImGui::ButtonBehavior (handle_x_bb, iHandleID, &hovered, &held);
230+ if (held)
225231 {
226232 float const fCursorPosX = ImGui::GetMousePos ().x - vStart.x ;
227233
@@ -231,8 +237,10 @@ static bool SliderScalar3D(char const* pLabel, float* pValueX, float* pValueY, f
231237 }
232238 // else if (ImGui::IsMouseHoveringRect(vHandlePosY - ImVec2(fHandleRadius, fHandleRadius) - vSecurity, vHandlePosY + ImVec2(fHandleRadius, fHandleRadius) + vSecurity) &&
233239 // ImGui::IsMouseDown(ImGuiMouseButton_Left))
234- pressed = ImGui::ButtonBehavior (handle_y_bb, ImGui::GetID (" ##HandleY" ), &hovered, &held);
235- if (hovered && held)
240+ iHandleID = ImGui::GetID (" ##HandleY" );
241+ ImGui::KeepAliveID (iHandleID);
242+ pressed = ImGui::ButtonBehavior (handle_y_bb, iHandleID, &hovered, &held);
243+ if (held)
236244 {
237245 float const fCursorPosY = ImGui::GetMousePos ().y - vStart.y ;
238246
0 commit comments