Skip to content

fix(tcell_driver): deliver MouseRight and MouseMiddle click events#104

Open
matsest wants to merge 1 commit intojesseduffield:masterfrom
matsest:fix/mouse-secondary-middle
Open

fix(tcell_driver): deliver MouseRight and MouseMiddle click events#104
matsest wants to merge 1 commit intojesseduffield:masterfrom
matsest:fix/mouse-secondary-middle

Conversation

@matsest
Copy link
Copy Markdown

@matsest matsest commented Apr 5, 2026

Bug

In tcell_driver.go, the event loop tracks mouse drag state.

When a mouse button is pressed, dragState should be set to MAYBE_DRAGGING so the click event is sent. On release, it should be reset to NOT_DRAGGING.

The bug: Only MouseLeft (ButtonPrimary) sets dragState on press and resets it on release.

Later, when checking if the event should be delivered:

if !wheeling {
    switch dragState {
    case NOT_DRAGGING:
        return GocuiEvent{Type: eventNone}  // ← MouseRight/Middle always hits this!
    ...

Since dragState was never set for MouseRight or MouseMiddle, it remains NOT_DRAGGING, causing the event to be discarded before delivery.

Fix

Set dragState on press and reset it on release for secondary and middle mouse buttons, matching the existing behavior for primary button. Previously these events were silently discarded because dragState was never set, causing the event loop to always hit NOT_DRAGGING case and return eventNone.

Set dragState on press and reset it on release for secondary and
middle mouse buttons, matching the existing behavior for primary
button. Previously these events were silently discarded because
dragState was never set, causing the event loop to always hit
NOT_DRAGGING case and return eventNone.
@matsest
Copy link
Copy Markdown
Author

matsest commented Apr 5, 2026

First, thanks for maintaining this excellent fork, and the awesome lazygit and lazydocker!

Found this when I tried implementing use of MouseRight and MouseMiddle in an application I built that uses this gocui-implementation, and couldn't get any of them to work. This fix made gocui pick up the mouse clicks successfully, when testing a local version of this package.

I don't know if you accept contributions regarding other usage than lazygit/lazydocker, so fully understand if that is the case. Just didn't want to maintain a fork for such a small patch, when this is already there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant