gcla / gowid

Compositional widgets for terminal user interfaces, written in Go, inspired by urwid.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature request] Handling mouse double-click in button widget

Peter2121 opened this issue · comments

It would be nice that button widget handles mouse double-click events at the same manner it handles KeyEnter event - call w.Click(app).

Hi @Peter2121 - I've pushed up experimental support for double-click handlers in the button widget. You can update to this version of gowid by running the following inside the directory of your project's main module:

go get github.com/gcla/gowid@doubleclick

You can add a double-click handler to your button in a similar way to how you would add a regular click handler:

w.OnDoubleClick(..)

I've set it up so that if a double-click handler runs, and a regular click handler is also registered, the regular click handler is suppressed. But I'm not sure about this behavior. Do let me know what you think.

I confirm that a double-click handler I added runs correctly in my project. I don't have a special click handler, but I see that the button is correctly selected if I double-click it, so the 'internal' widget click handler is correctly fired. This behavior is 100% OK for me.

All merged now - I'll close this :-)