ocornut / imgui

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

Drawing a button over a text box does not work. #3180

Closed blakat360 closed 6 months ago

blakat360 commented 4 years ago

Version/Branch of Dear ImGui:

Version: 9f9ff84 Branch: Master

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_opengl3.cpp + imgui_impl_glfw.cpp

issue

Extension of this issue, using the same system and version of imgui. https://github.com/ocornut/imgui/issues/3149#issue-604604185

Code:

//start frame
ImGui::SetCursorPos(0,0);
//*str = "foo";
ImGui::InputText( (std::string("###")+label).c_str(), str, ImVec2( 25, 25 );
SetItemAllowOverlap();
ImGui::SetCursorPos(0,0);
ImGui::Button("2", ImVec2(50, 50));
//end frame

When I try this, "foo" shows up over button 2 and any clicks are passed to the text box. The SetItemAllowOverlap function doesnt help here and I see no flags that could be helpful.

I want the input to captured by the button 2 and for the text box's text to not be seen.

What's the best way to proceed?

ocornut commented 6 months ago

AFAIK this is working now:

static char buf[64];
ImGui::SetCursorPos({ 0, 0 });
ImGui::SetNextItemAllowOverlap();
ImGui::InputText("blah", buf, 64);
ImGui::SetCursorPos({ 0, 0 });
ImGui::Button("2", ImVec2(50, 50));

But your repro is confusing:

ImGui::InputText( (std::string("###")+label).c_str(), str, ImVec2( 25, 25 );

InputText() does not take a size. If your issue was actually about InputTextMultiline() then yes we have an issue, topic is #7009