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

Grabbing scrollbar doesn't work on my backend #8310

Closed
Meakk opened this issue Jan 11, 2025 · 4 comments
Closed

Grabbing scrollbar doesn't work on my backend #8310

Meakk opened this issue Jan 11, 2025 · 4 comments

Comments

@Meakk
Copy link

Meakk commented Jan 11, 2025

Version/Branch of Dear ImGui:

Version 1.91.5

Back-ends:

Custom

Compiler, OS:

Windows

Full config/build information:

No response

Details:

My Issue/Question:

I have an application based on VTK and created my own backend for both rendering and interaction handling by forwarding event from VTK to imgui.
Everything works well but I can't grab the scrollbar to scroll the widget content.

Using mouse wheel or clicking on the empty space does scroll it properly.
However, when clicking on the scrollbar, the color changes until I release the button which makes me think imgui correctly receive the mouse down/up events, but I cannot move the scrollbar. The mouse position is also properly updated between the down and up event.

In the attached video, you can see the mouse wheel working, then simple click on empty space working too, but grabbing failing.

Any idea of what could happen here?

Screenshots/Video:

Recording.2025-01-11.214834.mp4

Minimal, Complete and Verifiable Example code:

No response

@ocornut
Copy link
Owner

ocornut commented Jan 12, 2025

You can see the cursor blinking in the text field at the bottom, you probably have code stealing the focus and active item every frame and preventing other items to be used.

@Meakk
Copy link
Author

Meakk commented Jan 12, 2025

That was the problem, thanks!
I'm calling ImGui::SetKeyboardFocusHere(-1); to make sure the input box always have the focus. Commenting out this line fixes this issue.
However, I want to keep this behavior. Should I manually disable the focus call when the mouse button is currently pressed, or is there something in ImGui I need to call?

@ocornut
Copy link
Owner

ocornut commented Jan 12, 2025

However, I want to keep this behavior.

You want to keep which behavior? The behavior of scrollbar and any other widgets not being usable?

Try to describe in details what you actually want and you’ll find your answer. Perhaps you want to focus the input text when its parent window is appearing? Perhaps you want to focus the input text when the parent window is focused and no item is active ? Perhaps you want to focus the input text every time something has been input into it ?
All those things you can express in code with appropriate function calls (IsWindowAppering(), IsWindowFocused(), IsAnyItemActive() etc.).

@Meakk
Copy link
Author

Meakk commented Jan 12, 2025

As long as the window is visible, I want to be able to type in the input text, even if I click outside of the input text. It must keep the focus, except if the user interacts with the scrollbar.

I tried ImGui::IsAnyItemActive() and it seems to work.
Thanks for pointing it out!

@Meakk Meakk closed this as completed Jan 12, 2025
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