Create text input in place of another active widget (e.g. used when doing a CTRL+Click on drag/slider widgets) FIXME: Facilitate using this in variety of other situations.
| 3365 | // Create text input in place of another active widget (e.g. used when doing a CTRL+Click on drag/slider widgets) |
| 3366 | // FIXME: Facilitate using this in variety of other situations. |
| 3367 | bool ImGui::TempInputText(const ImRect& bb, ImGuiID id, const char* label, char* buf, int buf_size, ImGuiInputTextFlags flags) |
| 3368 | { |
| 3369 | // On the first frame, g.TempInputTextId == 0, then on subsequent frames it becomes == id. |
| 3370 | // We clear ActiveID on the first frame to allow the InputText() taking it back. |
| 3371 | ImGuiContext& g = *GImGui; |
| 3372 | const bool init = (g.TempInputId != id); |
| 3373 | if (init) |
| 3374 | ClearActiveID(); |
| 3375 | |
| 3376 | g.CurrentWindow->DC.CursorPos = bb.Min; |
| 3377 | bool value_changed = InputTextEx(label, NULL, buf, buf_size, bb.GetSize(), flags | ImGuiInputTextFlags_MergedItem); |
| 3378 | if (init) |
| 3379 | { |
| 3380 | // First frame we started displaying the InputText widget, we expect it to take the active id. |
| 3381 | IM_ASSERT(g.ActiveId == id); |
| 3382 | g.TempInputId = g.ActiveId; |
| 3383 | } |
| 3384 | return value_changed; |
| 3385 | } |
| 3386 | |
| 3387 | static inline ImGuiInputTextFlags InputScalar_DefaultCharsFilter(ImGuiDataType data_type, const char* format) |
| 3388 | { |