epezent / implot

Immediate Mode Plotting
MIT License
4.66k stars 520 forks source link

Can't drag DragPoint or DragLineX in demo and my own code #355

Closed masterghui closed 2 years ago

masterghui commented 2 years ago

When I drag DragPoint or DragLine, It never moved. I tried in imgui sdl and glfw demo on my macos, but nothing different.

epezent commented 2 years ago

This sort of behavior is typically the result of calling CreateContext in the your update loop instead of during initialization. Are you by chance making that mistake?

If not can you tell me what ImGui version you're on. Thanks!

paolotherocker commented 2 years ago

I think I might have a similar problem. I am running ImPlot at the top of master and ImGui at the top o docking.

With the rect demo, I can drag the corners ok, but I can't drag the centre.

This sort of behavior is typically the result of calling CreateContext in the your update loop instead of during initialization. Are you by chance making that mistake?

I double checked, and I am indeed creating the context only once

masterghui commented 2 years ago

This sort of behavior is typically the result of calling CreateContext in the your update loop instead of during initialization. Are you by chance making that mistake?

If not can you tell me what ImGui version you're on. Thanks!

I checked it, only called ImGui::CreateContext and ImPlot::CreateContext() during initialization. My ImGui on commit eda7792b151d138e15df951578253b821ceed5a3

epezent commented 2 years ago

Hi, there does seem to be an issue with the latest ImGui. I am investigating.

epezent commented 2 years ago

It appears that several things are not working at the moment:

Each of these make use of ImGui::ButtonBehavior. @ocornut, any guesses on what caused the regression?

epezent commented 2 years ago

@masterghui , @paolotherocker -- please pull master and let me know if https://github.com/epezent/implot/commit/32a4617cd67354c57f2738c01f72392eac8605c1 resolves the issue.

@ocornut -- FYI, the fix was calling ImGui::KeepAliveID just before ImGui::ButtonBehavior. This was not necessary in the past, but seems to be now. TBD if this causes any issues; hopefully not.

EDIT: Possibly related to https://github.com/ocornut/imgui/commit/6d15a506faade602f70833898853aab8876c7270 or https://github.com/ocornut/imgui/commit/90386780e3071cfd73837070b34b23e2f62a2cec

paolotherocker commented 2 years ago

@epezent It does resolve the issue, thanks for sorting this out

masterghui commented 2 years ago

@epezent I pull master code and it works! Thanks for your work!

ocornut commented 2 years ago

The commit is https://github.com/ocornut/imgui/commit/90386780e3071cfd73837070b34b23e2f62a2cec (if you want to add a version number to your changelog or comments)

I will amend the changelog to surface this issue better for people using internals.

ocornut commented 1 year ago

KeepAliveID was moved from GetID() to ItemAdd(), were you calling ButtonBehavior() without ItemAdd() ? (That’s a bit unusual but also perfectly fine, some internal code doss it)