ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
61.15k stars 10.3k forks source link

Custom ToolTip for BeginTabItem #8035

Closed sonoro1234 closed 1 month ago

sonoro1234 commented 1 month ago

Version/Branch of Dear ImGui:

Version 1.91.2 docking

Back-ends:

imgui_impl_glfw.cpp + imgui_impl_opengl.cpp

Compiler, OS:

windows 10 mingw-w64

Full config/build information:

No response

Details:

My Issue/Question:

I need a custom Tooltip behaviour for TabItems. Tabs get label from v.shrt_name but when hovering should show long file_name. This is the code.

    if (ig.BeginTabBar("##Tabs", ig.lib.ImGuiTabBarFlags_NoTooltip)) then
        if (ig.BeginTabItem(v.shrt_name.."##"..i, nil,(i==new_doc) and ig.lib.ImGuiTabItemFlags_SetSelected or 0)) then
            if ig.IsItemHovered() then ig.SetTooltip(v.file_name) end
            if new_doc == i then new_doc = -1 end
            curr_opendoc = i
            v:Render()
            ig.EndTabItem();
        end
        ig.EndTabBar();
    end

The problem is that if ig.IsItemHovered() then ig.SetTooltip(v.file_name) end does not get called unless the tab is selected. How should I solve it?

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

No response

ocornut commented 1 month ago

The problem is that if ig.IsItemHovered() then ig.SetTooltip(v.file_name) end does not get called unless the tab is selected. How should I solve it?

Call it even when the tab is not selected?

bool open = BeginTabItem(...);
SetItemTooltip("your tooltip");
if (open)
{
   ..
   EndTabItem();
}
sonoro1234 commented 1 month ago

So obvious, Thanks!!