[Urwid] mouse_event() confusion
Rebecca Breu
rebecca at rbreu.de
Mon Jul 17 05:14:21 EDT 2006
Hi!
I have a problem with mouse events. I need a ListBox where the right
mouse button selects an entry and does some other stuff. My idea was
to subclass the ListBox and overwrite the mouse_event() like this:
class MyListBox(urwid.ListBox):
def mouse_event(self, size, event, button, col, row, focus):
"""Third mouse button click selects a widget."""
if event == "mouse press" and button == 3:
curses.beep()
#Pretend that the left button was pressed:
return urwid.ListBox.mouse_event(self, size, event, 1, col,
row, focus)
else:
return urwid.ListBox.mouse_event(self, size, event, button, col,
row, focus)
The problem: When I put the MyListBox into a Columns widget together
with another selectable widget, and that other widget is focused, then
right-clicking into the MyListBox doesn't change the focus (but I can
hear the beep). Whereas, when the focus is already in the MyListBox,
a right-click beeps and changes the focus as expected.
Another thing I noticed is that the mouse_event() functions seem to
return False all of the time. I understand that they should return True
if a key was handled? :-/
I attached the whole example program. Thanks in advance.
Rebecca
-------------- next part --------------
A non-text attachment was scrubbed...
Name: urwid_test2.py
Type: text/x-python
Size: 3050 bytes
Desc: not available
Url : http://lists.excess.org/pipermail/urwid/attachments/20060717/4f4e2649/urwid_test2.py
More information about the Urwid
mailing list