| 15 | }; |
| 16 | |
| 17 | static int InputTextCallback(ImGuiInputTextCallbackData* data) |
| 18 | { |
| 19 | InputTextCallback_UserData* user_data = (InputTextCallback_UserData*)data->UserData; |
| 20 | if (data->EventFlag == ImGuiInputTextFlags_CallbackResize) |
| 21 | { |
| 22 | // Resize string callback |
| 23 | // If for some reason we refuse the new length (BufTextLen) and/or capacity (BufSize) we need to set them back to what we want. |
| 24 | std::string* str = user_data->Str; |
| 25 | IM_ASSERT(data->Buf == str->c_str()); |
| 26 | str->resize(data->BufTextLen); |
| 27 | data->Buf = (char*)str->c_str(); |
| 28 | } |
| 29 | else if (user_data->ChainCallback) |
| 30 | { |
| 31 | // Forward to user callback, if any |
| 32 | data->UserData = user_data->ChainCallbackUserData; |
| 33 | return user_data->ChainCallback(data); |
| 34 | } |
| 35 | return 0; |
| 36 | } |
| 37 | |
| 38 | bool ImGui::InputText(const char* label, std::string* str, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) |
| 39 | { |