mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #972] Box.SetMouseCapture does not capture/consume events properly [+PR] #710
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#710
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 @GiGurra on GitHub (Apr 20, 2024).
Original GitHub issue: https://github.com/rivo/tview/issues/972
At present, it is not possible to consume events in the mouse event capture function. Even if you return nil, the event will not be marked as consumed. This causes (among other things)
Application.draw()to not fire properly, and essentially, means that any gui state changes you make inside the capture function, isn't rendered.The following code (from the Application event loop) shows where the draw call would be skipped when the wrong consume status is returned
The problem/bug exists in
Box.WrapMouseHandler, and I have created a PR with suggestion on how to fix this here: https://github.com/rivo/tview/pull/967As I understand the tview maintainers prefer an issue created together with a PR. Is this correct?
@rivo commented on GitHub (May 19, 2024):
In a sense, @digitallyserviced is right that we don't want to assume that an event that is intercepted and not passed on needs to result in the screen being redrawn. Let's say a primitive handles mouse movements and you want to disable them. You wouldn't want the screen to be redrawn every time the user moves the mouse in that case. So this is why I've closed your PR.
To be honest, this is something I simply forgot to implement. The mouse capture function should also return a
consumedflag (and acaptureprimitive). But I cannot simply add this now. Instead, my latest commit introduces aMouseConsumedaction which you can return, to indicate that you've consumed an event and that you want the screen to be redrawn. Sure, you could also callApplication.Draw()yourself but whenever possible, I want to allow access to this functionality without having to keep a global reference toApplication. (It's not always possible but it should be possible in the most common cases.)As for opening an issue alongside a PR, I would even suggest only opening an issue first, without a PR. (This is mentioned in the contributing guide.) Most PR's I get ignore important details, don't consider negative side effects, introduce unnecessary complexity, or simply lack the elegance I'd like to see in this project. Unfortunately, I have to reject most of them. So it's better to simply open an issue and we'll take it from there.