| 37 | }; |
| 38 | |
| 39 | static int InputTextCallback(ImGuiInputTextCallbackData* data) |
| 40 | { |
| 41 | InputTextCallback_UserData* user_data = (InputTextCallback_UserData*)data->UserData; |
| 42 | if (data->EventFlag == ImGuiInputTextFlags_CallbackResize) |
| 43 | { |
| 44 | // Resize string callback |
| 45 | // If for some reason we refuse the new length (BufTextLen) and/or capacity (BufSize) we need to set them back to what we want. |
| 46 | std::string* str = user_data->Str; |
| 47 | IM_ASSERT(data->Buf == str->c_str()); |
| 48 | str->resize(data->BufTextLen); |
| 49 | data->Buf = (char*)str->c_str(); |
| 50 | } |
| 51 | else if (user_data->ChainCallback) |
| 52 | { |
| 53 | // Forward to user callback, if any |
| 54 | data->UserData = user_data->ChainCallbackUserData; |
| 55 | return user_data->ChainCallback(data); |
| 56 | } |
| 57 | return 0; |
| 58 | } |
| 59 | |
| 60 | bool ImGui::InputText(const char* label, std::string* str, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) |
| 61 | { |