From 98dcaacfb590f4bbce2283a61fbef1911ed1b1cf Mon Sep 17 00:00:00 2001 From: Ian Jauslin Date: Wed, 20 Oct 2021 20:59:22 -0400 Subject: [PATCH] Correct unselection --- cross.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/cross.py b/cross.py index ae9a170..c912070 100644 --- a/cross.py +++ b/cross.py @@ -278,18 +278,18 @@ class Cross_painter(Widget): # only respond to touch in area 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 if touch.button=="right": 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) # add to list self.crosses.append(new) + + # unselect all crosses + for sel in self.selected: + sel.selected=False + self.selected=[] + self.draw() # select cross @@ -299,6 +299,13 @@ class Cross_painter(Widget): # find cross under touch 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 elif self.modifiers==['s']: clicked=self.find_cross(Point(touch.x/Cross.size,touch.y/Cross.size))