change selected to undermouse

This commit is contained in:
Ian Jauslin 2021-10-20 11:07:45 -04:00
parent 32cfd341be
commit 0fe82c1006

View File

@ -220,8 +220,8 @@ class Cross_painter(Widget):
# list of crosses
self.crosses=[]
# selected cross
self.selected=None
# cross under mouse
self.undermouse=None
# app is used to share information between widgets
self.app=app
@ -232,7 +232,7 @@ class Cross_painter(Widget):
def reset(self):
self.crosses=[]
self.selected=None
self.undermouse=None
self.draw()
@ -260,13 +260,13 @@ class Cross_painter(Widget):
# select cross
if touch.button=="left":
# unselect
if self.selected!=None:
self.selected.selected=False
if self.undermouse!=None:
self.undermouse.selected=False
# select cross under touch
self.selected=self.find_cross(Point(touch.x/Cross.size,touch.y/Cross.size))
if self.selected!=None:
self.selected.selected=True
# find cross under touch
self.undermouse=self.find_cross(Point(touch.x/Cross.size,touch.y/Cross.size))
if self.undermouse!=None:
self.undermouse.selected=True
self.draw()
@ -274,8 +274,8 @@ class Cross_painter(Widget):
def on_touch_move(self,touch):
if self.collide_point(*touch.pos):
# only move on left click
if touch.button=="left" and self.selected!=None:
self.selected.pos=self.check_move(Point(touch.x/Cross.size,touch.y/Cross.size),self.selected)
if touch.button=="left" and self.undermouse!=None:
self.undermouse.pos=self.check_move(Point(touch.x/Cross.size,touch.y/Cross.size),self.undermouse)
# redraw
self.draw()