[GH-ISSUE #1074] Mouse on linux terminal without X11 #778

Closed
opened 2026-03-04 01:07:41 +03:00 by kerem · 6 comments
Owner

Originally created by @igrag on GitHub (Feb 21, 2025).
Original GitHub issue: https://github.com/rivo/tview/issues/1074

Hello.
we are trying to develop a simple console gui on a system that doesn't have X11. Everhtning works excpet the mouse events. Logical because the terminal does not support mouse. But the mouse is there and we can see it in /dev/input and also it works with evtest.

Is it possible to inject MouseEvents in tview like this?
mouseEvent := tcell.NewEventMouse(x+offset, y, tcell.ButtonPrimary, tcell.ModNone)

If yes how could we send it globally to the app to the mainloop for dispatching?
Of course we will first start a goroutine watching the /dev/input/mice device.

Thank you.
Best Regards,
Giannis

Originally created by @igrag on GitHub (Feb 21, 2025). Original GitHub issue: https://github.com/rivo/tview/issues/1074 Hello. we are trying to develop a simple console gui on a system that doesn't have X11. Everhtning works excpet the mouse events. Logical because the terminal does not support mouse. But the mouse is there and we can see it in /dev/input and also it works with evtest. Is it possible to inject MouseEvents in tview like this? mouseEvent := tcell.NewEventMouse(x+offset, y, tcell.ButtonPrimary, tcell.ModNone) If yes how could we send it globally to the app to the mainloop for dispatching? Of course we will first start a goroutine watching the /dev/input/mice device. Thank you. Best Regards, Giannis
kerem closed this issue 2026-03-04 01:07:41 +03:00
Author
Owner

@igrag commented on GitHub (Feb 21, 2025):

First of all thank you for your reply.
Yes I have seen all the examples that are related to mouse handle, but my problem is more primitive.
The machine that this gui will run has no graphics stack like x11 or wayland or whatever.
So the tty console hasn't native mouse support.

What I have done and it seems that tview started to respond to mouse is this:

  1. I used this "github.com/holoplot/go-evdev" to run a goroutine that monitors /dev/input/event0.
  2. When a mouse event occurs it creates a mouse event like this:

mouseEvent := tcell.NewEventMouse(x, y, tcell.ButtonPrimary, tcell.ModNone)

  1. Then I send the event to tview like this
    app.QueueEvent(mouseEvent)

and tview responded, for example a button was pressed.

Maybe it is usefull to add this kind of funtionallity in the future for cases like this.

Best Regards,
Giannis

<!-- gh-comment-id:2675220743 --> @igrag commented on GitHub (Feb 21, 2025): First of all thank you for your reply. Yes I have seen all the examples that are related to mouse handle, but my problem is more primitive. The machine that this gui will run has no graphics stack like x11 or wayland or whatever. So the tty console hasn't native mouse support. What I have done and it seems that tview started to respond to mouse is this: 1. I used this "github.com/holoplot/go-evdev" to run a goroutine that monitors /dev/input/event0. 2. When a mouse event occurs it creates a mouse event like this: mouseEvent := tcell.NewEventMouse(x, y, tcell.ButtonPrimary, tcell.ModNone) 3. Then I send the event to tview like this app.QueueEvent(mouseEvent) and tview responded, for example a button was pressed. Maybe it is usefull to add this kind of funtionallity in the future for cases like this. Best Regards, Giannis
Author
Owner

@igrag commented on GitHub (Feb 21, 2025):

Yes, I tried but no response from tview.

<!-- gh-comment-id:2675519161 --> @igrag commented on GitHub (Feb 21, 2025): Yes, I tried but no response from tview.
Author
Owner

@igrag commented on GitHub (Feb 22, 2025):

Yes, I have response from the regular prompt with gpm. I can see the cursor moving at various locations. What I also did is to set the SetMouseCapture callback to have some feedback from mouse, but the callback never fired from gpm. This callback works fine in a typical ubuntu desktop console.

<!-- gh-comment-id:2676113095 --> @igrag commented on GitHub (Feb 22, 2025): Yes, I have response from the regular prompt with gpm. I can see the cursor moving at various locations. What I also did is to set the SetMouseCapture callback to have some feedback from mouse, but the callback never fired from gpm. This callback works fine in a typical ubuntu desktop console.
Author
Owner

@rivo commented on GitHub (Mar 26, 2025):

@igrag You could create your own tcell.Screen class which includes your functionality. Specifically, you will need to override the PollEvent() method.

Then you call Application.SetScreen() in tview to set the application to your own implementation.

<!-- gh-comment-id:2755134885 --> @rivo commented on GitHub (Mar 26, 2025): @igrag You could create your own [`tcell.Screen`](https://pkg.go.dev/github.com/gdamore/tcell/v2#Screen) class which includes your functionality. Specifically, you will need to override the `PollEvent()` method. Then you call [`Application.SetScreen()`](https://pkg.go.dev/github.com/rivo/tview#Application.SetScreen) in `tview` to set the application to your own implementation.
Author
Owner

@igrag commented on GitHub (Mar 27, 2025):

Thnak you @rivo for your suggestion. I will try to do it.

<!-- gh-comment-id:2759101652 --> @igrag commented on GitHub (Mar 27, 2025): Thnak you @rivo for your suggestion. I will try to do it.
Author
Owner

@rivo commented on GitHub (Aug 27, 2025):

Will close this for now. Feel to open a new issue if needed.

<!-- gh-comment-id:3229440848 --> @rivo commented on GitHub (Aug 27, 2025): Will close this for now. Feel to open a new issue if needed.
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#778
No description provided.