mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 13:25:51 +03:00
[GH-ISSUE #1074] Mouse on linux terminal without X11 #778
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#778
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 @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
@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:
mouseEvent := tcell.NewEventMouse(x, y, tcell.ButtonPrimary, tcell.ModNone)
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
@igrag commented on GitHub (Feb 21, 2025):
Yes, I tried but no response from tview.
@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.
@rivo commented on GitHub (Mar 26, 2025):
@igrag You could create your own
tcell.Screenclass which includes your functionality. Specifically, you will need to override thePollEvent()method.Then you call
Application.SetScreen()intviewto set the application to your own implementation.@igrag commented on GitHub (Mar 27, 2025):
Thnak you @rivo for your suggestion. I will try to do it.
@rivo commented on GitHub (Aug 27, 2025):
Will close this for now. Feel to open a new issue if needed.