Wrap text inside ImGui::Selectable

Sorry if this is really trivial, grep-ing through the source code did not give me an answer.

Basically I have an ImGui::Selectable with a really long text. I want to display it in a similar way to ImGui::TextWrapped while being able to select.

Any pointers would be greatly appreciated.


Hello Bogdan,
Unfortunatley it is not directly possible at the moment.

Right now the simplest work-around would be to perform the wrapping yourself.
You might calc CalcTextSizeA() with wrapping setting to obtain a size, use this size to create a Selectable() with an empty label (e.g. Selectable("##hidden", size)) then using ImDrawList->AddText() to render the text over it.

You may wrap the whole thing into your own function e.g. ImGui::MySelectableWrapped(). Remember you can add functions into the ImGui:: namespace from your own source files.

Thanks! For now I just went for a simple ImGui::TextWrapper with a separate button for copying the contents to the clipboard. I will try your solution as well when I get more free time and share the results.