I'm using a Urwid button and wonder if there's a way to handle keypress events directly on the button?
urwid.Button((item["customer"] + "/ " + item["case"]), button_press_pick_case,
user_data=item)
I know I can probably do this by capturing MainLoop's unhandled_input
and then finding the currently focused button, but I wonder if there's an easier way.
Thanks
It seems that for global shortcuts, the way to go is really the
unhandled_input
.If you want to make the button to answer to an additional key combination, you can edit the button's
CommandMap
, which is accessible through the_command_map
widget attribute, but it will only work when the button has the focus.