mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Implement new ImGui Input Text flag to move cursor to the end of char buffer
This commit is contained in:
parent
55b708c9fe
commit
d4dc9d7c3e
3
r5dev/thirdparty/imgui/include/imgui.h
vendored
3
r5dev/thirdparty/imgui/include/imgui.h
vendored
@ -1009,7 +1009,8 @@ enum ImGuiInputTextFlags_
|
||||
ImGuiInputTextFlags_NoUndoRedo = 1 << 16, // Disable undo/redo. Note that input text owns the text data while active, if you want to provide your own undo/redo stack you need e.g. to call ClearActiveID().
|
||||
ImGuiInputTextFlags_CharsScientific = 1 << 17, // Allow 0123456789.+-*/eE (Scientific notation input)
|
||||
ImGuiInputTextFlags_CallbackResize = 1 << 18, // Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow. Notify when the string wants to be resized (for string types which hold a cache of their Size). You will be provided a new BufSize in the callback and NEED to honor it. (see misc/cpp/imgui_stdlib.h for an example of using this)
|
||||
ImGuiInputTextFlags_CallbackEdit = 1 << 19 // Callback on any edit (note that InputText() already returns true on edit, the callback is useful mainly to manipulate the underlying buffer while focus is active)
|
||||
ImGuiInputTextFlags_CallbackEdit = 1 << 19, // Callback on any edit (note that InputText() already returns true on edit, the callback is useful mainly to manipulate the underlying buffer while focus is active)
|
||||
ImGuiInputTextFlags_AutoCaretEnd = 1 << 20 // Move the input text cursor automatically to the end of the buffer on initial focus.
|
||||
|
||||
// Obsolete names (will be removed soon)
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
|
9
r5dev/thirdparty/imgui/src/imgui_widgets.cpp
vendored
9
r5dev/thirdparty/imgui/src/imgui_widgets.cpp
vendored
@ -4048,6 +4048,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
||||
const bool user_scroll_active = is_multiline && state != NULL && g.ActiveId == GetWindowScrollbarID(draw_window, ImGuiAxis_Y);
|
||||
bool clear_active_id = false;
|
||||
bool select_all = false;
|
||||
bool auto_caret = false;
|
||||
|
||||
float scroll_y = is_multiline ? draw_window->Scroll.y : FLT_MAX;
|
||||
|
||||
@ -4090,6 +4091,12 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
||||
stb_textedit_initialize_state(&state->Stb, !is_multiline);
|
||||
}
|
||||
|
||||
if (flags & ImGuiInputTextFlags_AutoCaretEnd)
|
||||
{
|
||||
state->Stb.cursor = state->CurLenW;
|
||||
auto_caret = true;
|
||||
}
|
||||
|
||||
if (!is_multiline)
|
||||
{
|
||||
if (flags & ImGuiInputTextFlags_AutoSelectAll)
|
||||
@ -4230,7 +4237,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
||||
}
|
||||
state->CursorAnimReset();
|
||||
}
|
||||
else if (io.MouseClicked[0] && !state->SelectedAllMouseLock)
|
||||
else if (io.MouseClicked[0] && !state->SelectedAllMouseLock && !auto_caret)
|
||||
{
|
||||
// FIXME: unselect on late click could be done release?
|
||||
if (hovered)
|
||||
|
Loading…
x
Reference in New Issue
Block a user