单击IMGUI按钮时,如何防止点击背景

发布于 2025-01-27 04:01:24 字数 226 浏览 7 评论 0原文

单击IMGUI按钮时,如何防止点击背景 (例如,我单击“翻译”按钮,还单击背景)

”在此处输入图像描述”

How do I prevent clicking background when I click the IMGUI button
(e.g. I click the translate button and also click the background)

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

煮酒 2025-02-03 04:01:24

检查IMGUI是否要使用imgui :: getio()。wantcapturemouse捕获鼠标。如果确实这样做,就不会让事件进一步传播。

void Application::handleInput(InputEvent event) {

        // don't pass mouse and keyboard presses further if an ImGui widget is active
        auto& io = ImGui::GetIO();
        if (io.WantCaptureMouse || io.WantCaptureKeyboard) {
            return;
        }

        // ... event processing
    }
}

imgui常见问题: q:我如何确定是否将鼠标/键盘派遣到亲爱的imgui或我的应用程序?

Check whether ImGui wants to capture the mouse click using ImGui::GetIO().WantCaptureMouse. If it does then don't let the event propagate further.

void Application::handleInput(InputEvent event) {

        // don't pass mouse and keyboard presses further if an ImGui widget is active
        auto& io = ImGui::GetIO();
        if (io.WantCaptureMouse || io.WantCaptureKeyboard) {
            return;
        }

        // ... event processing
    }
}

ImGui FAQ: Q: How can I tell whether to dispatch mouse/keyboard to Dear ImGui or my application?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文