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