I want to have double-press mouse event for a program PuDB I am hacking for mouse controls. My first attempt was to modify its customized event loop and the result was good enough to me.
However, I thought I should make the Urwid to do the work. So I have this diff. It’s implemented in class Screen of raw_display.py. I found it’s pretty silly and ugly after I recalled there is a thing called input_filter.
Moreover, I must have forgot how normal GUI double-click event is signaled.
Original | Expected (strange :D) | Really should be like | |
---|---|---|---|
press | (suppressed) | press | press |
release | (suppressed) | release | release, click |
press | double press | press | press |
release | release | double press | release, click |
release | double click |
After I realized that I shouldn’t suppressed some events, I use input_filter to achieve the correct result. You can read my code here, and it’s easy to plug in.
loop = urwid.MainLoop(..., input_filter=double_press_input_filter(), ...)
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.