[PR #967] [CLOSED] Fix consume status of mouse events in custom capture #1084

Closed
opened 2026-03-04 01:09:21 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/rivo/tview/pull/967
Author: @GiGurra
Created: 4/19/2024
Status: Closed

Base: masterHead: mouse-capture-consume-events


📝 Commits (1)

  • 46d061f consume captured mouse events

📊 Changes

1 file changed (+3 additions, -0 deletions)

View changed files

📝 box.go (+3 -0)

📄 Description

At present, it is not possible to consume events in the mouse event capture function, even if you return nil. 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.

This PR hopefully fixes that. I couldn't find any tests to modify/change, do you need any other info?

The following code (from the Application event loop) shows where the draw call would be skipped when the wrong consume status is returned

case *tcell.EventMouse:
	consumed, isMouseDownAction := a.fireMouseActions(event)
	if consumed {
		a.draw()
	}
	a.lastMouseButtons = event.Buttons()
	if isMouseDownAction {
		a.mouseDownX, a.mouseDownY = event.Position()
	}

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/rivo/tview/pull/967 **Author:** [@GiGurra](https://github.com/GiGurra) **Created:** 4/19/2024 **Status:** ❌ Closed **Base:** `master` ← **Head:** `mouse-capture-consume-events` --- ### 📝 Commits (1) - [`46d061f`](https://github.com/rivo/tview/commit/46d061f15c21eeb83ec8e9fd4b5f2b3e2a17c31b) consume captured mouse events ### 📊 Changes **1 file changed** (+3 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `box.go` (+3 -0) </details> ### 📄 Description At present, it is not possible to consume events in the mouse event capture function, even if you return nil. 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. This PR hopefully fixes that. I couldn't find any tests to modify/change, do you need any other info? The following code (from the Application event loop) shows where the draw call would be skipped when the wrong consume status is returned ``` case *tcell.EventMouse: consumed, isMouseDownAction := a.fireMouseActions(event) if consumed { a.draw() } a.lastMouseButtons = event.Buttons() if isMouseDownAction { a.mouseDownX, a.mouseDownY = event.Position() } ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-04 01:09:21 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#1084
No description provided.