fix touch/no button

This commit is contained in:
Sander Land committed 2020-06-21 08:46:17 +02:00
1 parent 4bbfefd882
commit 2ac76d5a22
3 files changed
+7 -4

No files matched your search

+1
View File
@@ -379,6 +379,7 @@ class KaTrainGui(Screen, KaTrainBase):
or self.board_controls.collide_point(*touch.pos)
or self.controls.move_tree.collide_point(*touch.pos)
):
if touch.is_mouse_scrolling:
if touch.button == "scrollup":
self("redo")
elif touch.button == "scrolldown":
+5 -3
View File
@@ -60,11 +60,13 @@ class BadukPanWidget(Widget):
def on_touch_down(self, touch):
self.animating_pv = None # any click kills PV from label/move
self.draw_hover_contents()
if touch.button != "left":
if "button" in touch.profile and touch.button != "left":
return
self.check_next_move_ghost(touch)
def on_touch_move(self, touch):
if "button" in touch.profile and touch.button != "left":
return
return self.check_next_move_ghost(touch)
def on_mouse_pos(self, *args): # https://gist.github.com/opqopq/15c707dc4cffc2b6455f
@@ -92,10 +94,10 @@ class BadukPanWidget(Widget):
self.last_mouse_pos = pos
def on_touch_up(self, touch):
if touch.button != "left" or not self.gridpos_x:
if ("button" in touch.profile and touch.button != "left") or not self.gridpos_x:
return
katrain = self.katrain
if self.ghost_stone and touch.button == "left":
if self.ghost_stone and ("button" not in touch.profile or touch.button == "left"):
katrain("play", self.ghost_stone)
elif not self.ghost_stone:
xd, xp = self._find_closest(touch.x, self.gridpos_x)
+1 -1
View File
@@ -37,7 +37,7 @@ class MoveTreeCanvas(Widget):
katrain.update_state()
def on_touch_up(self, touch):
if touch.button == "left":
if "button" not in touch.profile or touch.button == "left":
node, (x, y) = min(
self.move_xy_pos.items(), key=lambda n_xy: abs(n_xy[1][0] - touch.x) + abs(n_xy[1][1] - touch.y)
)