mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 13:11:05 +01:00 
			
		
		
		
	IO: Renamed InputCharacters[], marked internal as was always intended. AddInputCharacter() goes into a queue which can receive as many characters as needed during the frame. This is useful for automation to not have an upper limit on typing speed. Will later transition key/mouse to use the event queue later.
This commit is contained in:
		
							
								
								
									
										28
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								imgui.cpp
									
									
									
									
									
								
							| @@ -363,6 +363,7 @@ CODE | ||||
|  When you are not sure about a old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files. | ||||
|  You can read releases logs https://github.com/ocornut/imgui/releases for more details. | ||||
|  | ||||
|  - 2019/01/04 (1.67) - renamed io.InputCharacters[], marked internal as was always intended. Please don't access directly, and use AddInputCharacter() instead! | ||||
|  - 2018/12/10 (1.67) - renamed io.ConfigResizeWindowsFromEdges to io.ConfigWindowsResizeFromEdges as we are doing a large pass on configuration flags. | ||||
|  - 2018/10/12 (1.66) - renamed misc/stl/imgui_stl.* to misc/cpp/imgui_stdlib.* in prevision for other C++ helper files. | ||||
|  - 2018/09/28 (1.66) - renamed SetScrollHere() to SetScrollHereY(). Kept redirection function (will obsolete). | ||||
| @@ -1164,22 +1165,23 @@ ImGuiIO::ImGuiIO() | ||||
| // - on Windows you can get those using ToAscii+keyboard state, or via the WM_CHAR message | ||||
| void ImGuiIO::AddInputCharacter(ImWchar c) | ||||
| { | ||||
|     const int n = ImStrlenW(InputCharacters); | ||||
|     if (n + 1 < IM_ARRAYSIZE(InputCharacters)) | ||||
|     { | ||||
|         InputCharacters[n] = c; | ||||
|         InputCharacters[n+1] = '\0'; | ||||
|     } | ||||
|     InputQueueCharacters.push_back(c); | ||||
| } | ||||
|  | ||||
| void ImGuiIO::AddInputCharactersUTF8(const char* utf8_chars) | ||||
| { | ||||
|     // We can't pass more wchars than ImGuiIO::InputCharacters[] can hold so don't convert more | ||||
|     const int wchars_buf_len = sizeof(ImGuiIO::InputCharacters) / sizeof(ImWchar); | ||||
|     ImWchar wchars[wchars_buf_len]; | ||||
|     ImTextStrFromUtf8(wchars, wchars_buf_len, utf8_chars, NULL); | ||||
|     for (int i = 0; i < wchars_buf_len && wchars[i] != 0; i++) | ||||
|         AddInputCharacter(wchars[i]); | ||||
|     while (*utf8_chars != 0) | ||||
|     { | ||||
|         unsigned int c = 0; | ||||
|         utf8_chars += ImTextCharFromUtf8(&c, utf8_chars, NULL); | ||||
|         if (c > 0 && c <= 0xFFFF) | ||||
|             InputQueueCharacters.push_back((ImWchar)c); | ||||
|     } | ||||
| } | ||||
|  | ||||
| void ImGuiIO::ClearInputCharacters() | ||||
| { | ||||
|     InputQueueCharacters.resize(0); | ||||
| } | ||||
|  | ||||
| //----------------------------------------------------------------------------- | ||||
| @@ -3713,7 +3715,7 @@ void ImGui::EndFrame() | ||||
|  | ||||
|     // Clear Input data for next frame | ||||
|     g.IO.MouseWheel = g.IO.MouseWheelH = 0.0f; | ||||
|     memset(g.IO.InputCharacters, 0, sizeof(g.IO.InputCharacters)); | ||||
|     g.IO.InputQueueCharacters.resize(0); | ||||
|     memset(g.IO.NavInputs, 0, sizeof(g.IO.NavInputs)); | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user