jroimartin / gocui

Minimalist Go package aimed at creating Console User Interfaces.
BSD 3-Clause "New" or "Revised" License
9.92k stars 608 forks source link

DeleteView() should remove the associated key bindings with the view #32

Closed dcu closed 8 years ago

dcu commented 9 years ago

It seems like delete view is not removing the associated key bindings and it causes issues on dynamic UIs.

jroimartin commented 9 years ago

Keybindings are assigned at Gui level, not at View level. So, I feel that deleting a View should not affect keybindings. What about adding a new function like the next one?

func (g *Gui) DeleteKeybinding(viewname string, key interface{}, mod Modifier) error
dcu commented 9 years ago

What's the purpose of a key binding on a view that should no longer exist? I think it's confusing and hard to debug.

On Sat, Oct 3, 2015, 5:14 AM Roi Martin notifications@github.com wrote:

Keybindings are assigned at Gui level, not at View level. So, I feel that deleting a View should not affect to keybindings. What about adding a new function like the next one?

func (g *Gui) DeleteKeybinding(viewname string, key interface{}, mod Modifier) error

— Reply to this email directly or view it on GitHub https://github.com/jroimartin/gocui/issues/32#issuecomment-145234582.

jroimartin commented 8 years ago

Sorry for my really really late response. I've been very busy with other projects.

One case could be, for instance, this one: https://github.com/jroimartin/gocui/blob/master/_examples/demo.go#L105

You can set-up keybindings for all the views you know you will show, so it is not needed to reassign them each time you add/delete the views. One case where this is useful is, for example, dialogs. Also you can group all the keybinding settings in one place and execute them only once.

jroimartin commented 8 years ago

Closed due to inactivity. Feel free to reopen if you want to continue the discussion.

leerumler commented 8 years ago

Looks like I'm a little late to the party, but I would love to see the ability to delete keybindings implemented. I'm currently working on a project, and I found myself needing to create six views that are almost entirely identical because I need to set different keybindings on each of them. None of the views should ever be active at the same time, so being able to re-use that view with different keybindings would really simplify the code.

jroimartin commented 8 years ago

Hi @leerumler,

I've just added *Gui.DeleteKeybinding in 2a0623774fea2f2326126a71f1099a0a395e004c. Is it enough? :)

leerumler commented 8 years ago

Sorry for the late response on this, but yeah, that will work perfectly! Thank you!