vsg-dev / vsgImGui

Integration of VulkanSceneGraph with ImGui
MIT License
43 stars 28 forks source link

io.AddKeyEvent() does nothing #39

Closed rolandhill closed 1 year ago

rolandhill commented 1 year ago

Hi Everyone,

I looked at this all yesterday and can't figure it out. Either I'm just missing something or there is a bug in our implementation of ImGui 1.89+.

My original attempt to convert vsgImGui to ImGui 1.89 used io.AddKeyEvent() to submit the key to the ImGui queue. It all made sense from the documents, built OK and ran, but no keystrokes appeared in the ImGui controls.

@kannode added io.AddInputCharacter() to the KeyPressEvent to submit ASCII characters to a separate character stream queue in the same KeyPressEvent. The ImGui controls now receive the characters and show them as expected, however characters outside the ASCII range don't appear. We could just expand the range that goes to io.AddInputCharacter(), but I don't think it is the correct way to do it. Everything I have read and looking through the other backends, io.AddKeyEvent() should be the way to go.

Also, if you comment out the two io.AddKeyEvent() lines, then there is no change to the function of the program because it is only getting keyboard input from AddInputCharacter(). But, all the other backends that I've checked and documents use AddKeyEvent().

I've stepped through the code in a debugger and still can't figure out. Most other backends also use SetKeyEventNativeData(), but the documents indicate that it shouldn't be necessary.

Does anyone have any insight to this? @kannode, did you uncover more information about AddkeyEvent() while creating your PR?

Regards, Roland

kannode commented 1 year ago

I believe I saw AddInputCharacter in the glfw imgui integration.

On Mon, Jan 16, 2023 at 8:03 PM Roland Hill @.***> wrote:

Hi Everyone,

I looked at this all yesterday and can't figure it out. Either I'm just missing something or there is a bug in our implementation of ImGui 1.89+.

My original attempt to convert vsgImGui to ImGui 1.89 used io.AddKeyEvent() to submit the key to the ImGui queue. It all made sense from the documents, built OK and ran, but no keystrokes appeared in the ImGui controls.

@kannode https://github.com/kannode added io.AddInputCharacter() to the KeyPressEvent to submit ASCII characters to a separate character stream queue in the same KeyPressEvent. The ImGui controls now receive the characters and show them as expected, however characters outside the ASCII range don't appear. We could just expand the range that goes to io.AddInputCharacter(), but I don't think it is the correct way to do it. Everything I have read and looking through the other backends, io.AddKeyEvent() should be the way to go.

Also, if you comment out the two io.AddKeyEvent() lines, then there is no change to the function of the program because it is only getting keyboard input from AddInputCharacter(). But, all the other backends that I've checked and documents use AddKeyEvent().

I've stepped through the code in a debugger and still can't figure out. Most other backends also use SetKeyEventNativeData(), but the documents indicate that it shouldn't be necessary.

Does anyone have any insight to this? @kannode https://github.com/kannode, did you uncover more information about AddkeyEvent() while creating your PR?

Regards, Roland

— Reply to this email directly, view it on GitHub https://github.com/vsg-dev/vsgImGui/issues/39, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHWFHIP4ARD3QHNT2GZOIZ3WSXVU7ANCNFSM6AAAAAAT5I6HOM . You are receiving this because you were mentioned.Message ID: @.***>

-- S https://www.nodein.com/uresh K. Kannan, Ph.D., Chief Scientist, Nodein https://www.nodein.com

kannode commented 1 year ago

@rolandhill

robertosfield commented 1 year ago

Is this issue now resolved?

kannode commented 1 year ago

Yes