Components outside windows ?

Hi,

To draw rectangles outside of a window, I apparently need to do this outside of begin/end but they don’t receive events

How can I achieve this ?

void DrawNode(ImVec2 node_pos, float node_size, int i)
{
ImGui::SetNextWindowPos(node_pos);
ImGui::SetNextWindowSize(ImVec2(node_size, node_size));
ImGui::Begin(“##node”, nullptr,
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize |
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoBackground |
ImGuiWindowFlags_NoInputs);

// Create a unique ID string by appending i
std::string id_str = "##node_btn_" + std::to_string(i);
ImGui::InvisibleButton(id_str.c_str(), ImVec2(node_size, node_size));

if (ImGui::IsItemHovered()) {
    SDL_Log("Hovered node index: %d", i); >>>>>> not firing
}

if (ImGui::IsItemClicked()) {
    SDL_Log("Clicked node index: %d", i); >>>>>> not firing
}

ImGui::End();

ImDrawList* draw_list = ImGui::GetForegroundDrawList();
draw_list->AddRectFilled(node_pos, ImVec2(node_pos.x + node_size, node_pos.y + node_size), IM_COL32(255, 0, 0, 255));

}

void UpdateComponentNodes(std::shared_ptr state)
{
const float node_size = 10.0f;
ImDrawList* draw_list = ImGui::GetForegroundDrawList();

ImVec2 win_pos = ImVec2(state->x,state->y);
ImVec2 win_size = ImVec2(state->w,state->h);
//SDL_Log("%f %f %f %f",win_pos.x,win_pos.y,win_size.x,win_size.y);

int input_count = 2;
int output_count = 2;

// Draw input nodes (red squares) left OUTSIDE window
for (int i = 0; i < input_count; ++i) {
    float y = win_pos.y + 40.0f + i * (node_size + 5);
    ImVec2 node_pos(win_pos.x - node_size - 2, y);  // 2 px margin outside

    DrawNode(node_pos,node_size,i);
}

}

I call it outside of Begin/End

ImGui::Begin(state->title.c_str(),nullptr); //ImGuiWindowFlags_AlwaysAutoResize
ImGui::End();
UpdateComponentNodes(state);

Thanks for your help