MCPcopy Create free account
hub / github.com/Aegel5/SimpleSwitcher / InputTextDeactivateHook

Method InputTextDeactivateHook

imgui_tiny_app/imgui/imgui_widgets.cpp:4565–4583  ·  view source on GitHub ↗

As InputText() retain textual data and we currently provide a path for user to not retain it (via local variables) we need some form of hook to reapply data back to user buffer on deactivation frame. (#4714) It would be more desirable that we discourage users from taking advantage of the "user not retaining data" trick, but that more likely be attractive when we do have _NoLiveEdit flag available.

Source from the content-addressed store, hash-verified

4563// It would be more desirable that we discourage users from taking advantage of the "user not retaining data" trick,
4564// but that more likely be attractive when we do have _NoLiveEdit flag available.
4565void ImGui::InputTextDeactivateHook(ImGuiID id)
4566{
4567 ImGuiContext& g = *GImGui;
4568 ImGuiInputTextState* state = &g.InputTextState;
4569 if (id == 0 || state->ID != id)
4570 return;
4571 g.InputTextDeactivatedState.ID = state->ID;
4572 if (state->Flags & ImGuiInputTextFlags_ReadOnly)
4573 {
4574 g.InputTextDeactivatedState.TextA.resize(0); // In theory this data won't be used, but clear to be neat.
4575 }
4576 else
4577 {
4578 IM_ASSERT(state->TextA.Data != 0);
4579 IM_ASSERT(state->TextA[state->TextLen] == 0);
4580 g.InputTextDeactivatedState.TextA.resize(state->TextLen + 1);
4581 memcpy(g.InputTextDeactivatedState.TextA.Data, state->TextA.Data, state->TextLen + 1);
4582 }
4583}
4584
4585static int* ImLowerBound(int* in_begin, int* in_end, int v)
4586{

Callers

nothing calls this directly

Calls 1

resizeMethod · 0.45

Tested by

no test coverage detected