Skip to content
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

Android: button rendered as clicked after being released #6627

Open
polishcode opened this issue Jul 21, 2023 · 8 comments
Open

Android: button rendered as clicked after being released #6627

polishcode opened this issue Jul 21, 2023 · 8 comments

Comments

@polishcode
Copy link

Version/Branch of Dear ImGui:

Version: 1.87

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_android.cpp
Compiler: Android NDK/clang
Operating System: Android 13

My Issue/Question:

On Android, after clicking a button it stays rendered as in active/pressed state. It is getting rendered as inactive only after another button/item is clicked.

image

Standalone, minimal, complete and verifiable example:

Build and run android sample shipped with the library, click the button.

@plakapenka
Copy link

plakapenka commented Jul 21, 2023

try in init

io.AddMouseSourceEvent(ImGuiMouseSource_TouchScreen);

in my opinion this is not a pressed state, but just a cursor over the button

@polishcode
Copy link
Author

No change unfortunately. In both types of initialization (with/without your suggestion) input event handler (android_app* app->onInputEvent) is called twice upon button press. Inspecting those two events further down imgui impl:

event 1:
event type 2 AINPUT_EVENT_TYPE_MOTION
event action 0 AMOTION_EVENT_ACTION_DOWN
tool type defaults to touch screen
button down triggered with down == true

event 2:
event type 2 AINPUT_EVENT_TYPE_MOTION
event action 1 AMOTION_EVENT_ACTION_UP
tool type defaults to touch screen
button down triggered with down == false

So looks like the control logic works well, the rendering however does not follow.

@ocornut
Copy link
Owner

ocornut commented Jul 21, 2023

It’s not a rendering issue it is that the backend should submit a mouse leaving (AddMousePosEvent(-FLT_MAX,-FLT_MAX)) invalid position) event after the touch release. We haven’t formalized that design accross backends. It would also prevent certain actions such as long hovering for tooltips from happening.

@polishcode
Copy link
Author

Thanks for info @ocornut. Will try to add triggering of that event after event 2 described above. In my case tooltips are not required, so that should not be a problem.

@polishcode
Copy link
Author

@ocornut your suggestion worked fine for me, thank you for that.
Regarding this ticket. In my specific case - it is resolved. But generally - as you mentioned - requires additional work on Android's backend. Please close/keep it open accordingly.

@ocornut ocornut changed the title android: button rendered as clicked after being released Android: button rendered as clicked after being released Jul 24, 2023
@tpecholt
Copy link

tpecholt commented Jul 4, 2024

This issue is likely to affect all users trying to use ImGui on Android. The tooltips are not used much in Android so it would be nice to see this resolved.

@ocornut
Copy link
Owner

ocornut commented Jul 4, 2024

Main problem is i don’t know how to build/test the Android backend at this point. Passing me instructions how to do that with eg an emulator would probably help its maintenance.

@tpecholt
Copy link

tpecholt commented Jul 4, 2024

I use Android Studio and it works painlessly most of the time. I am attaching a short guide for it.

android-setup.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants