mirror of
https://github.com/rivo/tview.git
synced 2026-04-27 05:45:49 +03:00
[GH-ISSUE #667] Example of using mouse events #489
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#489
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @githubedu on GitHub (Nov 5, 2021).
Original GitHub issue: https://github.com/rivo/tview/issues/667
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
@rivo commented on GitHub (Nov 8, 2021):
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 theactionargument (typeMouseAction) isMouseLeftDownand do whatever you need to do.Let me know if this helps.
@githubedu commented on GitHub (Nov 16, 2021):
Thank you Rivo,
The
SetMouseCaptureis 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
MouseLeftDownand keep active the motor untilMouseLeftUp.Best regards.
@markusressel commented on GitHub (Sep 13, 2023):
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 😉
@mikayzo commented on GitHub (Feb 15, 2024):
jesus f****** christ, took me half a day to find this f****** comment and fix the f****** mouse issues i had. bless you sir
@rivo commented on GitHub (Apr 3, 2024):
I added some clarifications regarding the activation of mouse handling, see
github.com/rivo/tview@a22293bda9.