Skip to content

Mouse released event captured by ImGui when click is owned by application #1392

Closed
@Moka42

Description

@Moka42

Hi Omar,

ImGui tells information to the user application so they can capture/discard the inputs according to the input owner.
But when a mouse drag starts from the application but ends above an ImGui window, the mouse released event is captured by ImGui.
This is a problem because the application will still continue the drag event as ImGui tells the application to capture/discard the mouse release event.

To avoid the issue this change in ImGui::NewFrame fixed the problem but may have introduced some others :

if (g.IO.MouseClicked[i])
    g.IO.MouseDownOwned[i] = (g.HoveredWindow != NULL) || (!g.OpenPopupStack.empty());
mouse_any_down |= g.IO.MouseDown[i];
// g.IO.MouseReleased[i] added in condition because when mouse drag starts from engine and finishes above ImGui window,
// mouse released event was captured by ImGui.
// Initial check : if (g.IO.MouseDown[i])
if (g.IO.MouseDown[i] || g.IO.MouseReleased[i])
    if (mouse_earliest_button_down == -1 || g.IO.MouseClickedTime[mouse_earliest_button_down] > g.IO.MouseClickedTime[i])
        mouse_earliest_button_down = i;

Is it a safe change or does it introduce some incorrect behaviors ?
Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions