-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InputText/InputTextMultiline doesn't detect enter/new line/carriage return using other input device #2113
Comments
Hello @zivler , Your question is ambiguous and ill-defined. We have no idea what your barcode system is, how it works and how it is expected to work. |
There is the possibility that it is outputting a "NumPad Return" key down event instead of a regular one. In this case you may merge https://github.com/ocornut/imgui/pull/2005/files and wire it in SDL. If that is indeed your issue let us know, that would be an extra case for merging #2005. |
Hi Omar.Thank you for the response.Sorry if my issue is not that clear.From what i understand from the code (correct me if i'm wrong), the InputText flag "ImGuiInputTextFlags_EnterReturnsTrue" would add a carriage return \r and/or the new line \n to the array of characters when the enter key (or the assigned key) is pressed. This would not be a problem when we are using a regular keyboard since we can always assign any key to "Enter" whether it's in the numeric. In the case of other input device (where in my case I have tried the barcode scanner to enter the text), the device would pass a string together with the carriage return and new line to it so when it is read into a standard input stream it would automatically go to a new line (\r\n). I am not sure why the InputText and the InputTextMultiline would only read the valid array of characters and skip the escape sequence \r\n. So in this case when i tried the InputTextMultiline and use the barcode scanner to read a barcode, it would not move to the next line but I have no issue when I tried it on for example 'Notepad' or 'Excel'. |
The description for that flag says "Return 'true' when Enter is pressed (as opposed to when the value was modified)", so that is incorrect.
This is because our input handling mechanism is using the Enter KEY to trigger a new line, and filtering the \r\n Characters. There is a distinction between keys and characters in most systems (including Windows). Because we handle many options and code-paths (with keyboard modifiers etc.) it is more natural for us to be checking the keys here. I assume your scanner only output characters. If your scanner provide an instantaneous character output one ugly workaround would be to do:
to replace the characters 13 ('\r') with characters 10 ('\n') when passing them to io.AddInputCharacter() and cancelling the corresponding key-press (if any). |
Thanks.I tried that but still the same (i.e. can not go to new line/detect carriage). I think the 'InputText' skips the delimiters and just focus on handling key presses. What I can think of is just having a condition that the input stream from the barcode scanner will have 10 or more characters (for example) then sending '\n' when condition is fulfilled: |
You can setup InputText callbacks to replace and add characters.
… On 6 Oct 2018, at 10:15, zivler ***@***.***> wrote:
Thanks.I tried that but still the same (i.e. can not go to new line/detect carriage). I think the 'InputText' skips the delimiters and just focus on handling key presses. What I can think of is just having a condition that the input stream from the barcode scanner will have 10 or more characters (for example) then sending '\n' when condition is fulfilled:
ImGui::InputText("Input", InputBuf, IM_ARRAYSIZE(InputBuf), ...
if ((InputBuf != NULL && strlen(InputBuf)>=10)...
But this is just ugly (>.<) and not flexible solution.
How and where do I add the condition that the when '\r' is detected in the 'InputBuf' it will automatically perform a new line '\n'?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
thanks for the tip.i might need to study again until i grasp the structure..i tried again and realized the inputtext is reading the ‘\r\n’ from the barcode scanner but not that consistent.it might be the input stream is filtered right away before detecting the escape sequence..and trying to put a delay will have noticeable lag in the overall program. |
Version/Branch of Dear ImGui:
1.63
Back-end file/Renderer/OS:
Back-ends: imgui_impl_sd2.cpp + imgui_impl_opengl2.cpp
OS: Windows 10 32-bit
Compiler: MinGW
My Issue/Question:
Hello. I am trying out imgui's features but haven't tried making a project yet and i am quite new. Just studying the demo from the sample binaries. I would like to try something that use other input device (like a barcode scanner) for the input. In the "Console" example, I have tried using a scanner for the input but it doesn't detect the carriage return. I have also tried the InputTextMultiline but the same. Is there a way to do this without so much modification on the imgui code?
Standalone, minimal, complete and verifiable example:
N/A
The text was updated successfully, but these errors were encountered: