Closed hazbo closed 8 years ago
I realise that mouse clicks and key bindings don't sounds like they go together so much - however termbox seems to group them together, sort of. Do you think mouse events should be kept a bit more separate from that standard keybinding stuff you've already written?
They way I've done it so far would allow the user to do something like this
if err := g.SetKeybinding("main", gocui.MouseLeft, gocui.ModNone, doSomething); err != nil {
return err
}
First of all, sorry for my late response! I've been really busy working on other projects.
On the other hand, thanks for your contribution. I have added full mouse support in faa12e105a1f0da348ec3ece5cf9380f1268baa9 based on your initial work. Basically it allows to bind mouse buttons to views (or globally) and detects which View have been clicked before executing the matching keybinding. What do you think? :)
BTW there is an example here: https://github.com/jroimartin/gocui/blob/master/_examples/mouse.go
Hey, sorry it's taken a while for me to get back to this. I've had a look and I think it's great. This is the sort of thing that will be great for menus, dialog windows, buttons and that sort of thing etc...
I see this as work in progress, for now. In terms of the public API, all the end user has to do is something like g.EnableMouse = true. I think this is reasonable and may not have to really change. Although I think the way it's used with KeyBindings should maybe be changed. We need to expose the X and Y of the click event - I'm not sure if this is possible currently, although Gui has an unexported event field of type termbox.Event that I believe contains this information.
Mouse support is something I need for a project I'm using Gocui, I noticed there was an issue open in relation to this so I figured I'd send back what I've started already.
Thanks for making gocui - it's awesome.