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

About ImGui::ButtonBehavior Function #3495

Closed
YuDang1024 opened this issue Sep 28, 2020 · 4 comments
Closed

About ImGui::ButtonBehavior Function #3495

YuDang1024 opened this issue Sep 28, 2020 · 4 comments

Comments

@YuDang1024
Copy link

I saw this post in the discussion forum:
https://github.com/ocornut/imgui/issues/3379
This is exactly what I need, but there are some problems:
If I want to use the method you provided, can I only monitor the window generated by the Begin() function?
I use Begin("A") to generate window A,
Then in window A, use BeginChild("B") to generate child window B,
Then I use:
CurID = g.HoveredWindow->ID; CurRect = g.HoveredWindow->Rect();
Get the required data,Use for ButtonBehavior function,
Treat CurID and CurRect as the first and second parameters of the ButtonBehavior function.
In other words, I want to use this method to simulate the dragging action in the child window.
But it seems that the child window cannot be the same as the root window. I don't know where is the problem ?

@YuDang1024
Copy link
Author

YuDang1024 commented Sep 28, 2020

This is my interface structure:
image
this is my code:
image

I have followed your suggestion and put this function after BeginChild() and before EndChild().
But when my mouse hits the lower left corner of the sub-window, the CurID and CurRect data has been correctly obtained, but it cannot be dragged by the mouse.
I use this function because I want to provide users with a more comfortable operating environment on the mobile terminal.
Thanks, looking forward to your answer!!

@YuDang1024
Copy link
Author

I read the source code of IsWindowFocused function,
May have understood its role,
It can run on my device now, but there are still some problems in the middle of the two drags, which may be because Lua is not a reference value. Or I can solve this problem by recording the last location

@YuDang1024
Copy link
Author

This is my Lua code:
For your reference, I did it on a mobile device.
`function LTouchEventHandle:ScrollWhenDraggingOnVoid()
local io = ImGui.GetIO();
local mouse_delta = io.MouseDelta
MouseDelta = ImVec2(0.0, -mouse_delta.y)
local g = ImGui.GetCurrentContext();
local window = g.HoveredWindow;

if ImGui.IsWindowFocused(ImGuiFocusedFlags_.ImGuiFocusedFlags_ChildWindows) then
    if window ~= nil then
        local posScroll = window.Scroll
        ImGui.SetScrollY(window, posScroll.y + mouse_delta.y);
    end
end

end`

@ocornut
Copy link
Owner

ocornut commented Sep 30, 2020

Hello, I don't understand your issue but have answered in #3379.
If your issue appears to be solved, can we close this?

@ocornut ocornut closed this as completed Nov 4, 2020
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