GUI - do something when dragging a button
Posted: 27 Jul 2021, 06:53
I want this short code to get working.
I know you can monitor for LButtonDown like here in the first example https://lexikos.github.io/v2/docs/commands/OnMessage.htm#Examples
But I think the way I'm trying to achieve my goal would be more elegant and I guess should be possible.
Please could you tell me whether it's just wrong or just some minor adjustment is needed?
- something similar to button.OnEvent("Click", LButtonDown) - but I want the callback to happen when LButton is down, not later when is up.
Code: Select all
G := Gui()
button := G.Add("Button", "vbutton", "Drag me somewhere")
button.OnCommand(0x0201, LButtonDown) ; invalid callback function
LButtonDown() {
msgbox "LButtonDown"
; waiting here for LButtonUp
; then getMousePos and do something
}
G.Show()
But I think the way I'm trying to achieve my goal would be more elegant and I guess should be possible.
Please could you tell me whether it's just wrong or just some minor adjustment is needed?
- something similar to button.OnEvent("Click", LButtonDown) - but I want the callback to happen when LButton is down, not later when is up.