mirror of
https://github.com/dbarzin/pandora-box.git
synced 2025-07-19 13:29:42 +02:00
new mouse click
This commit is contained in:
parent
30bd482836
commit
ebe7d8742b
1 changed files with 7 additions and 19 deletions
|
@ -1,24 +1,12 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import curses
|
mouse = open( "/dev/input/mice", "rb" )
|
||||||
|
|
||||||
screen = curses.initscr()
|
|
||||||
screen.keypad(1)
|
|
||||||
curses.curs_set(0)
|
|
||||||
curses.mousemask(curses.ALL_MOUSE_EVENTS | curses.REPORT_MOUSE_POSITION)
|
|
||||||
curses.flushinp()
|
|
||||||
curses.noecho()
|
|
||||||
screen.clear()
|
|
||||||
|
|
||||||
|
def waitMouseClick():
|
||||||
while True:
|
while True:
|
||||||
key = screen.getch()
|
buf = mouse.read(3)
|
||||||
screen.clear()
|
if ((buf[0] & 0x1)==1):
|
||||||
screen.addstr(0, 0, "key: {}".format(key))
|
break;
|
||||||
if key == curses.KEY_MOUSE:
|
|
||||||
_, x, y, _, button = curses.getmouse()
|
waitMouseClick()
|
||||||
screen.addstr(1, 0, "x, y, button = {}, {}, {}".format(x, y, button))
|
|
||||||
elif key == 27:
|
|
||||||
break
|
|
||||||
|
|
||||||
curses.endwin()
|
|
||||||
curses.flushinp()
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue