You need to add REPORT_MOUSE_POSITION
to your mousemask
:
mousemask(BUTTON1_CLICKED|BUTTON2_CLICKED|BUTTON3_CLICKED|BUTTON4_CLICKED|REPORT_MOUSE_POSITION)
Or perhaps just
mousemask(ALL_MOUSE_EVENTS)
Curses processes mouse clicks in the same stream as key presses. So you need to get your mouse events with getch
.
In your case, I recommend setting getch
to non-blocking read stdscr.timeout=0
and adding a case statement:
case getch
when KEY_MOUSE
m = getmouse
winx.addstr "Mouse Position: #{m.x} #{m.y} #{m.z}"
end
Unfortunately on my system this only reports mouse movement when I click, so you might be out of luck depending on your curses implementation/terminal.
If you aren't too afraid of C, I recommend reading the ncurses C documentation. Ruby's curses library is basically a direct translation of it.