Modifying the ImGui::InputText text #4099
jrynkiew
announced in
Old/Archived discussions
Replies: 1 comment
-
OK, I have discovered a similar project which already covers what I was attempting to do at https://github.com/BalazsJako/ImGuiColorTextEdit |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I have been trying for a while to figure out how to directly modify the ImGui::InputText text without performing all operations manally.
Basically, I am trying to use ImGui::InputText as the output for the ExampleAppConsole from the demo project, since the AddLog method in the demo does not allow the text to be selectable, only renders it on screen.
Currently, I am attempting to use the following code/pseudocode logic
Draw a ImGui::InputTextMultiline with a string consoleBuffer which I declare in the ExampleAppConsole struct, with a ImGuiInputTextFlags_ReadOnly flag.
ImGui::InputTextMultiline("Console", (char*)consoleBuffer.c_str(), strlen(consoleBuffer.c_str()), ImVec2(ImGui::GetWindowContentRegionMax().x, ImGui::GetWindowContentRegionMax().y), ImGuiInputTextFlags_ReadOnly);
In order to add output to this InputTextMultiline, I use the same logic as the ExampleAppConsole, so I use the ExecCommand function and manually append the consoleBuffer
I always make sure to add a newline character after each append, in order to imitate a terminal command line console.
I have two problems with this soluton:
As to my first problem, I am trying to solve it by doing a check inside InputTextEx by directly modifying the buffer just before it is passed to the AddText method
This solution sort of works, but it's definitely not ideal.
It looks like I will need to write a separate function, something like OutputTextMultiline, to specifically handle my usecase, unfortunately I am still new to ImGui and it will take me a lot of time.
Is there any way I can do something like this?
ImGui::GetInputTextState(ImGui::GetID("Console"))->InsertChar("text whatever")
This would solve my issues :)
Beta Was this translation helpful? Give feedback.
All reactions