Skip to content

Questions about ways to disable window scrolling #9147

@achabense

Description

@achabense

Version/Branch of Dear ImGui:

Version 1.92.2b

Back-ends:

Any (imgui_impl_sdl3.cpp + imgui_impl_sdlrenderer3.cpp)

Compiler, OS:

Any (MSVC + Win10)

Full config/build information:

No response

Details:

I have two related questions about ways to disable window-scrolling:

  1. About ctrl to disable scrolling:
    Currently, pressing ctrl will disable window scrolling. This is intentionally handled in the codebase, and I want to rely on this behavior (to assume the window won't be scrolled when using ctrl+wheel to set some custom values).

    imgui/imgui.cpp

    Lines 10295 to 10296 in 960921f

    if (g.IO.KeyCtrl)
    return;

    However, in the same function there is a comment about obsoleteness, and I cannot make sure - does it only apply to FontAllowUserScaling, or does it also apply to the ctrl-to-disable-scrolling behavior?

    imgui/imgui.cpp

    Lines 10276 to 10278 in 960921f

    // Zoom / Scale window
    // FIXME-OBSOLETE: This is an old feature, it still works but pretty much nobody is using it and may be best redesigned.
    if (wheel.y != 0.0f && g.IO.KeyCtrl && g.IO.FontAllowUserScaling)

  2. About custom way to disable scrolling:
    I want to further disable window scrolling under some custom conditions (e.g. when certain buttons are pressed / certain popups displayed). Currently I'm using ImGui::SetKeyOwner(ImGuiKey_MouseWheelY, ImGuiKeyOwner_Any, ImGuiInputFlags_LockThisFrame), which seems to work. However (for easier maintenance) what's the recommended way to do this?

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions