Search code examples
rustimgui

imgui Cannot have an empty ID at the root of a window. If you need an empty label, use ## and read the FAQ about how the ID Stack works


When i try to initialize imgui element without label, like so:

ui.slider("", 10, 40, &mut input_font_size)

i get following error

Assertion failed: (id != window->ID && "Cannot have an empty ID at the root of a window. If you need an empty label, use ## and read the FAQ about how the ID Stack works!"), function ItemAdd, file imgui.cpp, line 7793.

How should i fix it?


Solution

  • To create imgui element without a visible label, just place

    ##

    at the start of it like so:

    ui.slider("##slider1", 10, 40, &mut input_font_size)
    

    The example made with rust tweak of imgui - imgui-rs, for c++ solution is similar.