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

PlotLines() doesn't register its ID, does not work with SetItemKeyOwner() #7935

Closed
suncop opened this issue Aug 30, 2024 · 1 comment
Closed

Comments

@suncop
Copy link

suncop commented Aug 30, 2024

Version/Branch of Dear ImGui:

Branch: Docking, Main

Back-ends:

imgui_impl_metal.mm + imgui_impl_osx.mm

Compiler, OS:

clang, macos

Full config/build information:

No response

Details:

I've been trying for a bit to get SetItemKeyOwner(ImGuiKey_MouseWheelY) working with PlotLines(). Calling this does not seem to do anything in the current version (both main and docking) - scrolling still falls through to the parent window.
I noticed that PlotEx in imgui_widgets.cpp reads the following at line 8230 (line number is for a recent docking version):

if (!ItemAdd(total_bb, 0, &frame_bb)) // etc...

Is this intentional? I am not super familiar with the codebase so forgive me for asking rather than submitting a pull request. Changing this to:

if (!ItemAdd(total_bb, id, &frame_bb)) // etc...

fixes my issue, but not having a firm understanding of how id's/items etc work I am wary of leaving it this way.

-a

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

// Here's some code anyone can copy and paste to reproduce your issue
static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f };
ImGui::PlotLines("Frame Times", arr, IM_ARRAYSIZE(arr));
ImGui::SetItemKeyOwner(ImGuiKey_MouseWheelY);
ImGui::SetItemKeyOwner(ImGuiKey_MouseWheelX);

// scrolling will still happen if possible in the parent window
@ocornut ocornut changed the title PlotLines() does not work with SetItemKeyOwner() PlotLines() doesn't register its ID, does not work with SetItemKeyOwner() Sep 3, 2024
@ocornut
Copy link
Owner

ocornut commented Sep 3, 2024

Hello,

You pointed at exactly the right spot.

This was initially done by c2cb2a6 i believe as a way to prevent keyboard/gamepad navigation to land on the item, and 97ed97b did things half-way but you are right we should pass id to ItemAdd() + add ImGuiItemFlags_NoNav, which is what I have done now in afb15e9.

It has been this way mostly because people have really tried to add much interactions with those old plot functions..
Those functions are sort of stagnant and we encourage you to use ImPlot nowadays.
In fact I have taken advantage of the recent TextLinkOpenURL() function to add a link from the demo :)

Also linking to #3072.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants