Mouse on linux terminal without X11
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
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:
- I used this "github.com/holoplot/go-evdev" to run a goroutine that monitors /dev/input/event0.
- When a mouse event occurs it creates a mouse event like this:
mouseEvent := tcell.NewEventMouse(x, y, tcell.ButtonPrimary, tcell.ModNone)
- 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
Yes, I tried but no response from tview.
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.
@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.
Thnak you @rivo for your suggestion. I will try to do it.
Will close this for now. Feel to open a new issue if needed.