Correct unselection

This commit is contained in:
Ian Jauslin 2021-10-20 20:59:22 -04:00
parent fcd15da3f3
commit 98dcaacfb5

View File

@ -278,18 +278,18 @@ class Cross_painter(Widget):
# only respond to touch in area # only respond to touch in area
if self.collide_point(*touch.pos): if self.collide_point(*touch.pos):
# unselect
if touch.button!="left" or self.modifiers!=['s']:
for sel in self.selected:
sel.selected=False
self.selected=[]
# create new cross # create new cross
if touch.button=="right": if touch.button=="right":
if self.check_interaction_any(Point(touch.x/Cross.size,touch.y/Cross.size),None): if self.check_interaction_any(Point(touch.x/Cross.size,touch.y/Cross.size),None):
new=Cross(touch.x/Cross.size,touch.y/Cross.size) new=Cross(touch.x/Cross.size,touch.y/Cross.size)
# add to list # add to list
self.crosses.append(new) self.crosses.append(new)
# unselect all crosses
for sel in self.selected:
sel.selected=False
self.selected=[]
self.draw() self.draw()
# select cross # select cross
@ -299,6 +299,13 @@ class Cross_painter(Widget):
# find cross under touch # find cross under touch
self.undermouse=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.undermouse==None or not self.undermouse in self.selected:
# unselect all crosses
for sel in self.selected:
sel.selected=False
self.selected=[]
# shift-click # shift-click
elif self.modifiers==['s']: elif self.modifiers==['s']:
clicked=self.find_cross(Point(touch.x/Cross.size,touch.y/Cross.size)) clicked=self.find_cross(Point(touch.x/Cross.size,touch.y/Cross.size))