self.stdscr = stdscr
self.initialize(**object_dict)
self.map_all_colors()
self.draw_all_views()
curses.curs_set(0)
stdscr.keypad(1)
curses.mousemask(1)
curses.mousemask(curses.ALL_MOUSE_EVENTS)
# Once self.interact(..) returns a value, program will end.
# This is also the *start* of any pycurses project.
while True:
keypress = self.children[0].window.getch()
log_t(str(keypress))
if keypress == curses.KEY_MOUSE:
_, x, y, _, _ = curses.getmouse()
self.children[0].handle_mouse_click(x, y)
else:
response = self.interact(keypress)
if not response:
return 0
The logs indicate when the mouse is clicked, keypress returns '27' and then proceeds to move on and call self.interact() instead. how do I fix this?
I read a lot of forums, and even the documentation. Nothing works.
Getting mouse access involves not only setting the mousemask
, but enabling keypad
, which you have not done. Add this after the initialize
call and it will work:
self.children[0].window.keypad(1)