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

Is there Any way to set scrolling speed? #8206

Open
llxiaoyuan opened this issue Dec 4, 2024 · 2 comments
Open

Is there Any way to set scrolling speed? #8206

llxiaoyuan opened this issue Dec 4, 2024 · 2 comments

Comments

@llxiaoyuan
Copy link

llxiaoyuan commented Dec 4, 2024

Version/Branch of Dear ImGui:

Version 1.XX, Branch: XXX (master/docking/etc.)

Back-ends:

imgui_impl_XXX.cpp + imgui_impl_XXX.cpp

Compiler, OS:

win10

Full config/build information:

Is there Any way to set scrolling speed?

Details:

My Issue/Question:

XXX (please provide as much context as possible)

Screenshots/Video:

Is there Any way to set scrolling speed?

Minimal, Complete and Verifiable Example code:

@ocornut
Copy link
Owner

ocornut commented Dec 4, 2024

It's not possible for now. Also linking to #5628.

@yuvashrikarunakaran
Copy link

#include "imgui.h"

// Variable to control scroll position and speed
static float scrollSpeed = 10.0f; // Pixels per scroll
static float scrollPosition = 0.0f;

void ExampleScrollingSpeed()
{
ImGui::Begin("Scrollable Window");

// Scrollable child window
ImGui::BeginChild("ScrollableRegion", ImVec2(0, 300), true);

// Generate dummy content
for (int i = 0; i < 100; ++i)
{
    ImGui::Text("Item %d", i);
}

// Scroll control
if (ImGui::IsWindowHovered() && ImGui::GetIO().MouseWheel != 0.0f)
{
    // Adjust scroll position based on wheel movement and custom speed
    scrollPosition -= ImGui::GetIO().MouseWheel * scrollSpeed;
    scrollPosition = ImClamp(scrollPosition, 0.0f, ImGui::GetScrollMaxY());
    ImGui::SetScrollY(scrollPosition);
}

ImGui::EndChild();

// Slider to adjust scroll speed dynamically
ImGui::SliderFloat("Scroll Speed", &scrollSpeed, 1.0f, 50.0f, "%.1f pixels");

ImGui::End();

}

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

3 participants