ImGuizmo icon indicating copy to clipboard operation
ImGuizmo copied to clipboard

CanActivate needs rethinking

Open rokups opened this issue 4 years ago • 2 comments

I have integrated ImGuizmo into several projects by now. A recurring theme is me doing this:

   static bool CanActivate()
   {
      if (ImGui::IsMouseClicked(0) && /*!ImGui::IsAnyItemHovered() &&*/ !ImGui::IsAnyItemActive())
      {
         return true;
      }
      return false;
   }

This is required for applications that render imguizmo-controlled viewport into a texture and use InvisibleButton() over that texture to prevent window from getting dragged when grabbing this viewport.

Do you think it would be safe to permanently remove IsAnyItemHovered() check? Or do we need to make this behavior customizable by the user?

rokups avatar Oct 14 '20 06:10 rokups

I'd go with a #define in the .h to enable/disable that call. with a comment to explain your use case. As it doesn't need a runtime flag.

CedricGuillemet avatar Oct 14 '20 18:10 CedricGuillemet

One possible way to mitigate this is by setting ConfigWindowsMoveFromTitleBarOnly to true:

IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
io.ConfigWindowsMoveFromTitleBarOnly = true;
// ...

It still drags a Dear ImGui window around if both the title bar and the gizmo overlap, but at least now there are less chances of that happening.

AndreiDespinoiu avatar Oct 14 '20 23:10 AndreiDespinoiu