imgui icon indicating copy to clipboard operation
imgui copied to clipboard

Android: button rendered as clicked after being released

Open polishcode opened this issue 2 years ago • 9 comments

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.

polishcode avatar Jul 21 '23 09:07 polishcode

try in init

io.AddMouseSourceEvent(ImGuiMouseSource_TouchScreen);

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

plakapenka avatar Jul 21 '23 11:07 plakapenka

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.

polishcode avatar Jul 21 '23 13:07 polishcode

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.

ocornut avatar Jul 21 '23 21:07 ocornut

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 avatar Jul 22 '23 11:07 polishcode

@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.

polishcode avatar Jul 24 '23 06:07 polishcode

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.

tpecholt avatar Jul 04 '24 01:07 tpecholt

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.

ocornut avatar Jul 04 '24 05:07 ocornut

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

android-setup.txt

tpecholt avatar Jul 04 '24 12:07 tpecholt