MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / TempInputText

Method TempInputText

external/imgui/imgui_widgets.cpp:3718–3744  ·  view source on GitHub ↗

Create text input in place of another active widget (e.g. used when doing a Ctrl+Click on drag/slider widgets) - This must be submitted right after the item it is overlaying. FIXME: Facilitate using this in variety of other situations.

Source from the content-addressed store, hash-verified

3716// - This must be submitted right after the item it is overlaying.
3717// FIXME: Facilitate using this in variety of other situations.
3718bool ImGui::TempInputText(const ImRect& bb, ImGuiID id, const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data)
3719{
3720 // On the first frame, g.TempInputTextId == 0, then on subsequent frames it becomes == id.
3721 // We clear ActiveID on the first frame to allow the InputText() taking it back.
3722 ImGuiContext& g = *GImGui;
3723 ImGuiWindow* window = g.CurrentWindow;
3724
3725 const bool init = (g.TempInputId != id);
3726 if (init)
3727 ClearActiveID();
3728
3729 ImVec2 backup_pos = window->DC.CursorPos;
3730 window->DC.CursorPos = bb.Min;
3731 g.LastItemData.ItemFlags |= ImGuiItemFlags_AllowDuplicateId; // Using ImGuiInputTextFlags_MergedItem above will skip ItemAdd() so we poke here.
3732 bool value_changed = InputTextEx(label, NULL, buf, (int)buf_size, bb.GetSize(), flags | ImGuiInputTextFlags_TempInput | ImGuiInputTextFlags_AutoSelectAll, callback, user_data);
3733 KeepAliveID(id); // Not done because of ImGuiInputTextFlags_TempInput
3734 if (init)
3735 {
3736 // First frame we started displaying the InputText widget, we expect it to take the active id.
3737 IM_ASSERT(g.ActiveId == id);
3738 g.TempInputId = g.ActiveId;
3739 }
3740 if (g.ActiveId != id)
3741 g.TempInputId = 0;
3742 window->DC.CursorPos = backup_pos;
3743 return value_changed;
3744}
3745
3746// Note that Drag/Slider functions are only forwarding the min/max values clamping values if the ImGuiSliderFlags_AlwaysClamp flag is set!
3747// This is intended: this way we allow Ctrl+Click manual input to set a value out of bounds, for maximum flexibility.

Callers

nothing calls this directly

Calls 1

GetSizeMethod · 0.45

Tested by

no test coverage detected