mirror of
https://github.com/rivo/tview.git
synced 2026-04-27 05:45:49 +03:00
[GH-ISSUE #752] Application.SetMouseCapture(...) with event nil on Mouse[...]Click #551
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#551
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 @RasmusLindroth on GitHub (Aug 3, 2022).
Original GitHub issue: https://github.com/rivo/tview/issues/752
Hi,
If you set your own global mouse input handler with
Application.SetMouseCapture(...)that always returnsreturn nil, actionmouse clicks will get an event that is nil. Other mouse actions still gets an event. Because the event is nil I can't check what primitive that were clicked.Here comes an example program that shows this issue. Example output is presented below.
Example output:
A fix for this in application.go#407, but I don't know if this is the best fix or if it's causing some other issue.
@rivo commented on GitHub (Aug 11, 2022):
Thanks for letting me know about this. The issue here is that a "mouse up" event is followed by a "mouse click" event in one go because "mouse click" is a "secondary event" triggered by a sequence of "primary events" like "mouse down", "move move", and "mouse up". If you prevent the "mouse up" event by returning
nil, the "mouse click" event should not be fired. So the expected output is actually:The latest commit should result in this.
If you want to process the click event, you need to let the "mouse up" event come through.
@RasmusLindroth commented on GitHub (Aug 13, 2022):
Awesome and thank you :)