hoffstadt / DearPyGui

Dear PyGui: A fast and powerful Graphical User Interface Toolkit for Python with minimal dependencies
https://dearpygui.readthedocs.io/en/latest/
MIT License
13.24k stars 687 forks source link

support for WantCaptureMouse #2281

Open jacobnrohan opened 9 months ago

jacobnrohan commented 9 months ago

Is your feature request related to a problem? Please describe. Loving DearPyGui, but it appears to have no support for "WantCaptureMouse". This variable is described in the ocornut/imgui repo: "Set when Dear ImGui will use mouse inputs, in this case do not dispatch them to your main game/application (either way, always pass on mouse inputs to imgui). (e.g. unclicked mouse is hovering over an imgui window, widget is active, mouse was clicked over an imgui window, etc.)."

Describe the solution you'd like A method to access this variable would be helpful. A callback that occurs when this value changes would also be helpful, though not as important.

Additional context Feature does not appear in the dpg.demo.show_demo(), but appears in the dpg.show_imgui_demo(): Screenshot from 2024-02-11 16-04-12_edit

jacobnrohan commented 7 months ago

Hardly a good solution at all, but this is what I'm using currently:

hovered = []
for window in dpg.get_windows():
    state = dpg.get_item_state(window)
    if "hovered" in state.keys():
        hovered += [state["hovered"]]
any_hovered = any(hovered)

which is equivalent to: any_hovered = any([s["hovered"] for s in [dpg.get_item_state(w) for w in dpg.get_windows()] if ("hovered" in s.keys())])

This method does not support callbacks and often acts buggy when interacting with some widgets.