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

FIX: imgui hovering when other widget is focused #53

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/ImGuiRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,11 @@ void ImGuiRenderer::newFrame()
}
else
{
io.MousePos = ImVec2(-1,-1);
//https://github.com/ocornut/imgui/blob/031e152d292b386b7b6149e455924cfc6bab8c7c/imgui.h#L2048
// Mouse position, in pixels. Set to ImVec2(-FLT_MAX, -FLT_MAX) if mouse is unavailable (on another screen, etc.)
//https://github.com/ocornut/imgui/blob/fd943182bd9fe1d801e721a20a41dcde84be39d0/imgui.cpp#L679
// - 2017/08/25 (1.52) - io.MousePos needs to be set to ImVec2(-FLT_MAX,-FLT_MAX) when mouse is unavailable/missing. Previously ImVec2(-1,-1) was enough but we now accept negative mouse coordinates. In your backend if you need to support unavailable mouse, make sure to replace "io.MousePos = ImVec2(-1,-1)" with "io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX)".
io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX);
}

for (int i = 0; i < 3; i++)
Expand Down
9 changes: 8 additions & 1 deletion src/QtImGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ class QWidgetWindowWrapper : public QWindowWrapper {
return w->devicePixelRatioF();
}
bool isActive() const override {
return w->isActiveWindow();
// the window containing the widget top-level window that currently has focus
//return w->isActiveWindow();

// the widget is the one with focus among the window wigets
//return w->isActiveWindow() && w->hasFocus();

// the widget area is under the mouse, but it seems like other widgets being open/focused cancel it e.g. an open combo box
return w->isActiveWindow() && w->underMouse();
}
QPoint mapFromGlobal(const QPoint &p) const override {
return w->mapFromGlobal(p);
Expand Down