-2

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?

nojitsi
  • 351
  • 3
  • 13
  • 2
    You should [edit] your question to include an actual question and show a [mre] of how you produced this error – Alan Birtles Jan 10 '23 at 19:51
  • @AlanBirtles Hey, i just use this page as QA platform. Someone have this problem, he'll find it, because error is in the title. No need to answer, so no question! – nojitsi Jan 13 '23 at 12:11
  • Whilst there's nothing wrong with self-answering questions you should try and make sure the questions are generally useful to other people. The solution to your problem seems to already be stated in the error message? The "Q" in "QA" does stand for "question" so questions should ideally be written in the form of a question (e.g. "how do I create an imgui element with an empty label, when I try this ... I get the following error ...") – Alan Birtles Jan 13 '23 at 12:25
  • Ok, may be it's obevious for c++ user to put it in the string, but for noobie such as me, it's been confusing to see this message and find no solution across the internet. – nojitsi Jan 13 '23 at 12:35
  • The assert line you quoted LITERALLY gave you the answer which is to read Dear ImGui's FAQ about how the ID Stack works. – Omar Mar 23 '23 at 18:24
  • 1
    @Omar Ok, this time I checked closely and found the answer in FAQ. Previous time I have been frustrated because I saw question "how to make empty label" with the link on itself, and no answer. I honestly thought the link was broken or something, so I started to search it across the internet, which took a much more energy than it should. That's why this topic is here. – nojitsi Mar 27 '23 at 16:56

1 Answers1

2

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.

nojitsi
  • 351
  • 3
  • 13