Version/Branch of Dear ImGui:
- Version: 1.68 WIP
- Branch: master
Back-end/Renderer/Compiler/OS
- Back-ends: imgui_impl_sdl2.cpp + imgui_impl_opengl3.cpp
- Compiler: Clang 5.0 from Android NDK and VS2017 (15.9.x) on Windows
- Operating System: Windows 10.0.17763, Android 9
My Issue/Question:
So I've started running the official examples on mobile and encountered a small issue. As the title says, it's related solely to this API in the global style struct, I've set its value, it works as intended, but, I've noticed that touch input is just passed as mouse input in all of the official backends here (even the third party ones like SFML, openFrameworks, etc.) and the API itself doesn't have anything for passing touch events separately, this is understandable, my issue is actually, in the case of Android specifically, that in addition to the typical imprecise finger touches, there's more precise input events like styli (MotionEvent.TOOL_TYPE_STYLUS) and actual mice, unlike iOS (I might be wrong about this one). So I'd like to apply TouchExtraPadding to my global style but have an exclusion for such cases.
I've had a few ideas to work around this limitation; most of these are not the best ways nor optimal:
- Duplicating the mouse fields in
ImGuiIO as Touch/TouchDown or something similiar, until better touch support is implemented. This is like an API breaking change (?)
- A flag to distinguish touch events from actual mouse move events, and an additional check, probably here.
- A low-effort quick fix for the time being, setting
TouchExtraPadding in touch events, and changing it back to 0 for stylus/mouse events. Unsure how would that work, and this is counter-inituitive IMO.
- A tiny workaround, something like this:
#if defined(__ANDROID__)
ImGui::GetStyle().TouchExtraPadding = ImVec2(4.0F, 4.0F);
#endif
And this is kind of against Dear ImGui's platform independency concept IMO.
Again, these aren't the best ways to do this.
I know that Dear ImGui is designed to be used primarily with a mouse and keyboard, however, since gamepad support got added not so long ago, I think this would also make for a great addition and would make the library much nicer to use on a phone.
This issue is mostly intended to create a discussion, I'm not sure if it has been mentioned here before, I looked in some of the issues here but couldn't find anything closely related (#1237 #2074 #1470 #443). Sorry if this came off vague, also, I've filled the template just in case and I'm willing to send PRs if needed :)
Screenshots/Video

Not that relevant and taken on Windows, but instead it demonstrates that it should work only on touch input, not mouse.
Standalone, minimal, complete and verifiable example:
// In a typical Initialize() function:
ImGui::CreateContext();
ImGui::GetStyle().TouchExtraPadding = ImVec2(4.0F, 4.0F);
// ...
ImGui::Begin("Example Bug");
// This isn't just limited to buttons, it affects all other widgets as well
if (ImGui::Button("Testing button"))
{
// ...
}
ImGui::End();
Version/Branch of Dear ImGui:
Back-end/Renderer/Compiler/OS
My Issue/Question:
So I've started running the official examples on mobile and encountered a small issue. As the title says, it's related solely to this API in the global style struct, I've set its value, it works as intended, but, I've noticed that touch input is just passed as mouse input in all of the official backends here (even the third party ones like SFML, openFrameworks, etc.) and the API itself doesn't have anything for passing touch events separately, this is understandable, my issue is actually, in the case of Android specifically, that in addition to the typical imprecise finger touches, there's more precise input events like styli (
MotionEvent.TOOL_TYPE_STYLUS) and actual mice, unlike iOS (I might be wrong about this one). So I'd like to applyTouchExtraPaddingto my global style but have an exclusion for such cases.I've had a few ideas to work around this limitation; most of these are not the best ways nor optimal:
ImGuiIOas Touch/TouchDown or something similiar, until better touch support is implemented. This is like an API breaking change (?)TouchExtraPaddingin touch events, and changing it back to 0 for stylus/mouse events. Unsure how would that work, and this is counter-inituitive IMO.And this is kind of against Dear ImGui's platform independency concept IMO.
Again, these aren't the best ways to do this.
I know that Dear ImGui is designed to be used primarily with a mouse and keyboard, however, since gamepad support got added not so long ago, I think this would also make for a great addition and would make the library much nicer to use on a phone.
This issue is mostly intended to create a discussion, I'm not sure if it has been mentioned here before, I looked in some of the issues here but couldn't find anything closely related (#1237 #2074 #1470 #443). Sorry if this came off vague, also, I've filled the template just in case and I'm willing to send PRs if needed :)
Screenshots/Video
Not that relevant and taken on Windows, but instead it demonstrates that it should work only on touch input, not mouse.
Standalone, minimal, complete and verifiable example: