mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-25 05:06:59 +00:00
Merge pull request #44 from xythobuz/master
Added ImGuiInputTextFlags_EnterReturnsTrue
This commit is contained in:
commit
3cdb4fa456
@ -162,7 +162,6 @@
|
||||
- text edit: flag to disable live update of the user buffer.
|
||||
- text edit: field resize behaviour - field could stretch when being edited? hover tooltip shows more text?
|
||||
- text edit: pasting text into a number box should filter the characters the same way direct input does
|
||||
- text edit: allow code to catch user pressing Return (perhaps through disable live edit? so only Return apply the final value, also allow catching Return if value didn't changed)
|
||||
- settings: write more decent code to allow saving/loading new fields
|
||||
- settings: api for per-tool simple persistant data (bool,int,float) in .ini file
|
||||
- log: be able to right-click and log a window or tree-node into tty/file/clipboard?
|
||||
@ -3962,6 +3961,7 @@ bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlag
|
||||
|
||||
bool value_changed = false;
|
||||
bool cancel_edit = false;
|
||||
bool enter_pressed = false;
|
||||
if (g.ActiveId == id)
|
||||
{
|
||||
// Edit in progress
|
||||
@ -4001,7 +4001,7 @@ bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlag
|
||||
else if (IsKeyPressedMap(ImGuiKey_End)) edit_state.OnKeyboardPressed(is_ctrl_down ? STB_TEXTEDIT_K_TEXTEND | k_mask : STB_TEXTEDIT_K_LINEEND | k_mask);
|
||||
else if (IsKeyPressedMap(ImGuiKey_Delete)) edit_state.OnKeyboardPressed(STB_TEXTEDIT_K_DELETE | k_mask);
|
||||
else if (IsKeyPressedMap(ImGuiKey_Backspace)) edit_state.OnKeyboardPressed(STB_TEXTEDIT_K_BACKSPACE | k_mask);
|
||||
else if (IsKeyPressedMap(ImGuiKey_Enter)) { g.ActiveId = 0; }
|
||||
else if (IsKeyPressedMap(ImGuiKey_Enter)) { g.ActiveId = 0; enter_pressed = true; }
|
||||
else if (IsKeyPressedMap(ImGuiKey_Escape)) { g.ActiveId = 0; cancel_edit = true; }
|
||||
else if (is_ctrl_down && IsKeyPressedMap(ImGuiKey_Z)) edit_state.OnKeyboardPressed(STB_TEXTEDIT_K_UNDO); // I don't want to use shortcuts but we should probably have an Input-catch stack
|
||||
else if (is_ctrl_down && IsKeyPressedMap(ImGuiKey_Y)) edit_state.OnKeyboardPressed(STB_TEXTEDIT_K_REDO);
|
||||
@ -4122,6 +4122,9 @@ bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlag
|
||||
|
||||
RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
|
||||
|
||||
if ((flags & ImGuiInputTextFlags_EnterReturnsTrue) != 0)
|
||||
return enter_pressed;
|
||||
else
|
||||
return value_changed;
|
||||
}
|
||||
|
||||
|
1
imgui.h
1
imgui.h
@ -294,6 +294,7 @@ enum ImGuiInputTextFlags_
|
||||
ImGuiInputTextFlags_CharsHexadecimal = 1 << 1, // Allow 0123456789ABCDEFabcdef
|
||||
ImGuiInputTextFlags_AutoSelectAll = 1 << 2,
|
||||
ImGuiInputTextFlags_AlignCenter = 1 << 3,
|
||||
ImGuiInputTextFlags_EnterReturnsTrue = 1 << 4,
|
||||
};
|
||||
|
||||
// User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array
|
||||
|
Loading…
Reference in New Issue
Block a user