Commit c95f9294 authored by Sam Rushing's avatar Sam Rushing

handle some edge cases with touch events

parent 8b0be44e
...@@ -110,6 +110,7 @@ class field_conn (websocket): ...@@ -110,6 +110,7 @@ class field_conn (websocket):
self.on_mouse_move (int (event[1]), int (event[2])) self.on_mouse_move (int (event[1]), int (event[2]))
elif event[0] == 'TS': elif event[0] == 'TS':
tl = self.unpack_touch_list (event[1:]) tl = self.unpack_touch_list (event[1:])
self.last_touch_move = tl[0][0], tl[0][1]
self.on_mouse_down (tl[0][0], tl[0][1]) self.on_mouse_down (tl[0][0], tl[0][1])
elif event[0] == 'TM': elif event[0] == 'TM':
tl = self.unpack_touch_list (event[1:]) tl = self.unpack_touch_list (event[1:])
...@@ -118,13 +119,14 @@ class field_conn (websocket): ...@@ -118,13 +119,14 @@ class field_conn (websocket):
elif event[0] == 'TE': elif event[0] == 'TE':
# emulate mouse up by with saved last touch_move # emulate mouse up by with saved last touch_move
x0, y0 = self.last_touch_move x0, y0 = self.last_touch_move
self.on_mouse_up (x0, y0) if x0 is not None:
self.on_mouse_up (x0, y0)
self.last_touch_move = None, None
else: else:
W ('unknown event: %r\n' % (event,)) W ('unknown event: %r\n' % (event,))
return False return False
def unpack_touch_list (self, tl): def unpack_touch_list (self, tl):
W ('touch_list=%r\n' % (tl,))
return [ [int(y) for y in x.split('.')] for x in tl ] return [ [int(y) for y in x.split('.')] for x in tl ]
def on_mouse_down (self, x, y): def on_mouse_down (self, x, y):
...@@ -142,8 +144,9 @@ class field_conn (websocket): ...@@ -142,8 +144,9 @@ class field_conn (websocket):
#b = box (random.choice (colors), (x0+px, y0+py, x1+px, y1+py)) #b = box (random.choice (colors), (x0+px, y0+py, x1+px, y1+py))
#self.field.Q.insert (b) #self.field.Q.insert (b)
# 2) or move the window # 2) or move the window
self.move_window (x0-x1, y0-y1) if x0 is not None:
self.draw_window() self.move_window (x0-x1, y0-y1)
self.draw_window()
def on_mouse_move (self, x1, y1): def on_mouse_move (self, x1, y1):
x0, y0 = self.mouse_down x0, y0 = self.mouse_down
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment