mirror of
https://github.com/ocornut/imgui.git
synced 2026-03-27 23:37:03 -05:00
Internals: TempInputText: added callback/user_data parameters and made end of signature match InputText(). (#2718)
This commit is contained in:
@@ -3688,7 +3688,7 @@ namespace ImGui
|
|||||||
// InputText
|
// InputText
|
||||||
IMGUI_API bool InputTextEx(const char* label, const char* hint, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
|
IMGUI_API bool InputTextEx(const char* label, const char* hint, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
|
||||||
IMGUI_API void InputTextDeactivateHook(ImGuiID id);
|
IMGUI_API void InputTextDeactivateHook(ImGuiID id);
|
||||||
IMGUI_API bool TempInputText(const ImRect& bb, ImGuiID id, const char* label, char* buf, int buf_size, ImGuiInputTextFlags flags);
|
IMGUI_API bool TempInputText(const ImRect& bb, ImGuiID id, const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
|
||||||
IMGUI_API bool TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format, const void* p_clamp_min = NULL, const void* p_clamp_max = NULL);
|
IMGUI_API bool TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format, const void* p_clamp_min = NULL, const void* p_clamp_max = NULL);
|
||||||
inline bool TempInputIsActive(ImGuiID id) { ImGuiContext& g = *GImGui; return g.ActiveId == id && g.TempInputId == id; }
|
inline bool TempInputIsActive(ImGuiID id) { ImGuiContext& g = *GImGui; return g.ActiveId == id && g.TempInputId == id; }
|
||||||
inline ImGuiInputTextState* GetInputTextState(ImGuiID id) { ImGuiContext& g = *GImGui; return (id != 0 && g.InputTextState.ID == id) ? &g.InputTextState : NULL; } // Get input text state if active
|
inline ImGuiInputTextState* GetInputTextState(ImGuiID id) { ImGuiContext& g = *GImGui; return (id != 0 && g.InputTextState.ID == id) ? &g.InputTextState : NULL; } // Get input text state if active
|
||||||
|
|||||||
@@ -3696,7 +3696,7 @@ int ImParseFormatPrecision(const char* fmt, int default_precision)
|
|||||||
// Create text input in place of another active widget (e.g. used when doing a Ctrl+Click on drag/slider widgets)
|
// 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.
|
// - This must be submitted right after the item it is overlaying.
|
||||||
// FIXME: Facilitate using this in variety of other situations.
|
// FIXME: Facilitate using this in variety of other situations.
|
||||||
bool ImGui::TempInputText(const ImRect& bb, ImGuiID id, const char* label, char* buf, int buf_size, ImGuiInputTextFlags flags)
|
bool ImGui::TempInputText(const ImRect& bb, ImGuiID id, const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data)
|
||||||
{
|
{
|
||||||
// On the first frame, g.TempInputTextId == 0, then on subsequent frames it becomes == id.
|
// On the first frame, g.TempInputTextId == 0, then on subsequent frames it becomes == id.
|
||||||
// We clear ActiveID on the first frame to allow the InputText() taking it back.
|
// We clear ActiveID on the first frame to allow the InputText() taking it back.
|
||||||
@@ -3710,7 +3710,7 @@ bool ImGui::TempInputText(const ImRect& bb, ImGuiID id, const char* label, char*
|
|||||||
ImVec2 backup_pos = window->DC.CursorPos;
|
ImVec2 backup_pos = window->DC.CursorPos;
|
||||||
window->DC.CursorPos = bb.Min;
|
window->DC.CursorPos = bb.Min;
|
||||||
g.LastItemData.ItemFlags |= ImGuiItemFlags_AllowDuplicateId; // Using ImGuiInputTextFlags_MergedItem above will skip ItemAdd() so we poke here.
|
g.LastItemData.ItemFlags |= ImGuiItemFlags_AllowDuplicateId; // Using ImGuiInputTextFlags_MergedItem above will skip ItemAdd() so we poke here.
|
||||||
bool value_changed = InputTextEx(label, NULL, buf, buf_size, bb.GetSize(), flags | ImGuiInputTextFlags_TempInput | ImGuiInputTextFlags_AutoSelectAll);
|
bool value_changed = InputTextEx(label, NULL, buf, (int)buf_size, bb.GetSize(), flags | ImGuiInputTextFlags_TempInput | ImGuiInputTextFlags_AutoSelectAll, callback, user_data);
|
||||||
KeepAliveID(id); // Not done because of ImGuiInputTextFlags_TempInput
|
KeepAliveID(id); // Not done because of ImGuiInputTextFlags_TempInput
|
||||||
if (init)
|
if (init)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user