mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 13:11:05 +01:00 
			
		
		
		
	InputText: Fixed CTRL+Arrow or OSX double-click leaking the presence of spaces when ImGuiInputTextFlags_Password is used. (#4155, #4156) [@michael-swan]
This commit is contained in:
		| @@ -3597,11 +3597,12 @@ static void    STB_TEXTEDIT_LAYOUTROW(StbTexteditRow* r, STB_TEXTEDIT_STRING* ob | ||||
|     r->num_chars = (int)(text_remaining - (text + line_start_idx)); | ||||
| } | ||||
|  | ||||
| // When ImGuiInputTextFlags_Password is set, we don't want actions such as CTRL+Arrow to leak the fact that underlying data are blanks or separators. | ||||
| static bool is_separator(unsigned int c)                                        { return ImCharIsBlankW(c) || c==',' || c==';' || c=='(' || c==')' || c=='{' || c=='}' || c=='[' || c==']' || c=='|'; } | ||||
| static int  is_word_boundary_from_right(STB_TEXTEDIT_STRING* obj, int idx)      { return idx > 0 ? (is_separator(obj->TextW[idx - 1]) && !is_separator(obj->TextW[idx]) ) : 1; } | ||||
| static int  is_word_boundary_from_right(STB_TEXTEDIT_STRING* obj, int idx)      { if (obj->Flags & ImGuiInputTextFlags_Password) return 0; return idx > 0 ? (is_separator(obj->TextW[idx - 1]) && !is_separator(obj->TextW[idx]) ) : 1; } | ||||
| static int  STB_TEXTEDIT_MOVEWORDLEFT_IMPL(STB_TEXTEDIT_STRING* obj, int idx)   { idx--; while (idx >= 0 && !is_word_boundary_from_right(obj, idx)) idx--; return idx < 0 ? 0 : idx; } | ||||
| #ifdef __APPLE__    // FIXME: Move setting to IO structure | ||||
| static int  is_word_boundary_from_left(STB_TEXTEDIT_STRING* obj, int idx)       { return idx > 0 ? (!is_separator(obj->TextW[idx - 1]) && is_separator(obj->TextW[idx]) ) : 1; } | ||||
| static int  is_word_boundary_from_left(STB_TEXTEDIT_STRING* obj, int idx)       { if (obj->Flags & ImGuiInputTextFlags_Password) return 0; return idx > 0 ? (!is_separator(obj->TextW[idx - 1]) && is_separator(obj->TextW[idx]) ) : 1; } | ||||
| static int  STB_TEXTEDIT_MOVEWORDRIGHT_IMPL(STB_TEXTEDIT_STRING* obj, int idx)  { idx++; int len = obj->CurLenW; while (idx < len && !is_word_boundary_from_left(obj, idx)) idx++; return idx > len ? len : idx; } | ||||
| #else | ||||
| static int  STB_TEXTEDIT_MOVEWORDRIGHT_IMPL(STB_TEXTEDIT_STRING* obj, int idx)  { idx++; int len = obj->CurLenW; while (idx < len && !is_word_boundary_from_right(obj, idx)) idx++; return idx > len ? len : idx; } | ||||
| @@ -3627,7 +3628,7 @@ static void STB_TEXTEDIT_DELETECHARS(STB_TEXTEDIT_STRING* obj, int pos, int n) | ||||
|  | ||||
| static bool STB_TEXTEDIT_INSERTCHARS(STB_TEXTEDIT_STRING* obj, int pos, const ImWchar* new_text, int new_text_len) | ||||
| { | ||||
|     const bool is_resizable = (obj->UserFlags & ImGuiInputTextFlags_CallbackResize) != 0; | ||||
|     const bool is_resizable = (obj->Flags & ImGuiInputTextFlags_CallbackResize) != 0; | ||||
|     const int text_len = obj->CurLenW; | ||||
|     IM_ASSERT(pos <= text_len); | ||||
|  | ||||
| @@ -4067,7 +4068,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ | ||||
|         backup_current_text_length = state->CurLenA; | ||||
|         state->Edited = false; | ||||
|         state->BufCapacityA = buf_size; | ||||
|         state->UserFlags = flags; | ||||
|         state->Flags = flags; | ||||
|         state->UserCallback = callback; | ||||
|         state->UserCallbackData = callback_user_data; | ||||
|  | ||||
| @@ -4420,7 +4421,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ | ||||
|         } | ||||
|  | ||||
|         // Clear temporary user storage | ||||
|         state->UserFlags = 0; | ||||
|         state->Flags = ImGuiInputTextFlags_None; | ||||
|         state->UserCallback = NULL; | ||||
|         state->UserCallbackData = NULL; | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user