Conversation
|
Why? If you want different key binds (or none), you can use |
|
Well in my mind I find it easier to just call a function to stop those key binds from moving you around in the textview but still allow scrolling at the same time. |
|
I'm sorry but you haven't provided a reason yet why offering these key binds is a problem. Next someone comes and says they only want Vim bindings but no arrow movement. It's precisely the reason why I'm offering So unless there's a good reason to offer this specific option to all users of |
|
Oh ok would you mind explaining shortly how SetInputCapture would work for me being able to ignore the Vim bindings? I can't really find a way to ignore the Vim bindings with SetInputCapture. |
|
Sure, no problem. Here's an example: func main() {
app := tview.NewApplication()
textArea := tview.NewTextView().SetText(text)
textArea.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
switch event.Key() {
case tcell.KeyLeft, tcell.KeyRight, tcell.KeyUp, tcell.KeyDown:
return event // Allow arrow keys.
}
return nil // Ignore all others.
})
if err := app.SetRoot(textArea, true).EnableMouse(true).Run(); err != nil {
panic(err)
}
} |
|
Oh thanks! I can't believe it was as simple as just returning nil :( |
|
No problem. I'm glad I was able to help! |
This is to block the actions preformed when these keys are pressed in a textview