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

Allow dragging of controls #159

Open
shujidev opened this issue Dec 25, 2022 · 2 comments
Open

Allow dragging of controls #159

shujidev opened this issue Dec 25, 2022 · 2 comments
Labels

Comments

@shujidev
Copy link

shujidev commented Dec 25, 2022

Would it be possible to modify this condition
if uMsg == WM_LBUTTONUP and control == pLastMouseButtonDownControl
This would allow to trigger a mousebuttonup event on a different control so that a behavior like dragging elements or transference of attributes could be implemented

https://github.com/simonkrauter/NiGui/blob/master/src/nigui/private/windows/platform_impl.nim#L1282

@simonkrauter
Copy link
Owner

Difficult to say, how to implement drag and drop, I have never tried it.

@shujidev
Copy link
Author

shujidev commented Dec 26, 2022

Hi thank you for your interest I was misunderstanding your code, but I could find the real problem if you return PWndProcResult_True or return PWndProcResult_False at the end of a Mouse ButtonDown message windows will allow a mouseup event to be handled correctly on another control (my problem was that a mouseup event was triggered only on the same control mousedown was triggered)

Example try dragging a button into another button:

import nigui
app.init()
var window = newWindow("Gui")
window.show()
let button = newButton("button")
let button2 = newButton("button2")
let container = newLayoutContainer(Layout_Vertical)
window.add container
container.add button
container.add button2

button.onMouseButtonDown = proc(event: MouseEvent) = echo "mousedown Button"
button2.onMouseButtonDown = proc(event: MouseEvent) = echo "mousedown Button2"
button.onMouseButtonUp = proc(event: MouseEvent) = echo "mouseup Button"
button2.onMouseButtonUp = proc(event: MouseEvent) = echo "mouseup Button2"
    
app.run()

Then try after adding a return PWndProcResult_False to the end of the WM_LBUTTONDOWN message handling

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

No branches or pull requests

2 participants