bczsalba / pytermgui

Python TUI framework with mouse support, modular widget system, customizable and rapid terminal markup language and more!
https://ptg.bczsalba.com
MIT License
2.25k stars 56 forks source link

Enter doesn't activate buttons #127

Closed landersson closed 1 year ago

landersson commented 1 year ago

Hi,

I just noticed that pressing Enter does not activate UI buttons as expected under Linux.

https://github.com/bczsalba/pytermgui/blob/70f2f580256bc88037434319cc90b69041f545e2/pytermgui/widgets/button.py#L82

I've temporarily worked around the issue by changing the line above to:

 if (key == keys.RETURN or key=="\r") and self.onclick is not None:

But there is probably a better and more global way of making sure Enter (CTRL-M or '\r') activates a button.

bczsalba commented 1 year ago

That turned out to (mostly) be the solution! Just added keys.CARRIAGE_RETURN as \r, and used that instead. Thanks for the sHout~!