Closed githubedu closed 2 years ago
If you just want to be notified when a button was clicked, that's what Button.SetSelectedFunc()
is for. This will be called also when the user activates the button with the keyboard.
If you specifically want to check for a left mouse click (which is quite uncommon, but I don't know your use case), you use button.SetMouseCapture()
. Your function will be called for any mouse events directed at the button. You can then check if the action
argument (type MouseAction
) is MouseLeftDown
and do whatever you need to do.
Let me know if this helps.
Thank you Rivo,
The SetMouseCapture
is the one I was looking for.
I'm using to control motor axis. The user push a button on a touch screen, it activate on MouseLeftDown
and keep active the motor until MouseLeftUp
.
Best regards.
I want to leave a comment here mentioning that app.EnableMouse()
is required for any callbacks set via SetMouseCapture()
to be triggered.
Took me a while to figure out :wink:
I want to leave a comment here mentioning that
app.EnableMouse()
is required for any callbacks set viaSetMouseCapture()
to be triggered.Took me a while to figure out 😉
jesus f** christ, took me half a day to find this f** comment and fix the f** mouse issues i had. bless you sir
I added some clarifications regarding the activation of mouse handling, see https://github.com/rivo/tview/commit/a22293bda94443b8e287d94957beab835e45187b.
Hi,
I'm having issues to understand the usage of MouseActions.
In my case I want to call a function when "MouseLeftDown" is triggered or check that it has been triggered, when clicking in a button.
Could someone give me some basic advice where and how to use it?
Thank you