Closed Ikamyshev closed 1 year ago
Why ?
I create primitive WYSIWYG-editor. Editor containing widget panel and designer panel. For all elements i use dragndrop functions and it works well. But I want to be able to create frames by docking windows. When I click the frame button in the widget panel, a window is created which I drag onto the designer window. I want to remove a draggable window if it happens to be outside the designer. I hope I wrote clearly.
ImGui::Begin(); if (_isNew) { ImGuiContext& g = GImGui; ImGuiWindow window = g.CurrentWindow; ImGuiDockNode* dock_node = window->DockNode; if (ImGui::BeginPopupContextItem()) // <-- This is using IsItemHovered() { ImGui::EndPopup(); } if (ImGui::IsItemHovered()) { if (ImGui::IsMouseDragging(ImGuiMouseButton_Left)) { ImGui::StartMouseMovingWindowOrNode(window, dock_node, true); } if (ImGui::IsMouseReleased(ImGuiMouseButton_Left)) { std::cout << "parent window: " << window->ParentWindow << std::endl; _isNew = false; } } } ImGui::End();
if you check the value of the parent window, then it is always equal to zero.
I figured out the problem. When an item is docked, it moves out of the mouse cursor and therefore IsItemHovered did not fire. I apologize for the inconvenience.
I need different behavior for docked and separated windows.