From 3a1c63f4ce9e9a4ede9f0e23153472d471f0df3f Mon Sep 17 00:00:00 2001 From: DasMoorhuhn Date: Thu, 12 Dec 2024 04:33:57 +0100 Subject: [PATCH] add long right click detection --- vpet.py | 13 ++++++++++++- window_qt.py | 5 ++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/vpet.py b/vpet.py index 5011c8d..91e838f 100644 --- a/vpet.py +++ b/vpet.py @@ -65,6 +65,7 @@ class Activity: self.is_interacting_with_user = False def set_idle(self): + print('Setting idle') self.is_idle = True self.is_sleeping = False self.is_dreaming = False @@ -74,6 +75,7 @@ class Activity: self.is_interacting_with_user = False def set_sleeping(self): + print('Setting sleeping') self.is_idle = False self.is_sleeping = True self.is_moving = False @@ -81,6 +83,7 @@ class Activity: self.is_thinking = False def set_dreaming(self): + print('Setting dreaming') self.is_idle = False self.is_dreaming = True self.is_moving = False @@ -88,12 +91,14 @@ class Activity: self.is_thinking = False def set_moving(self): + print('Setting moving') self.is_idle = False self.is_moving = True self.is_sleeping = False self.is_dreaming = False def set_talking(self): + print('Setting talking') self.is_idle = False self.is_talking = True self.is_thinking = False @@ -106,6 +111,7 @@ class Activity: self.is_sleeping = False def set_interacting_with_user(self): + print('Setting interacting with user') self.is_idle = False self.is_sleeping = False self.is_dreaming = False @@ -124,6 +130,7 @@ class VPet: self.x_destination = 0 self.y_destination = 0 self.rotation = Rotate.up + self.p = 0 self.move = move self.draw = draw @@ -131,9 +138,13 @@ class VPet: self.activity = Activity() def action_loop(self): - print(f'Interacting with user: {self.activity.is_interacting_with_user}') + # print(f'Interacting with user: {self.activity.is_interacting_with_user}') if self.activity.is_interacting_with_user: return + self.move(self.x_postion, self.y_postion) + self.x_postion = self.pos().x() + 1 + self.y_postion = self.pos().y() + if self.activity.is_sleeping: pass diff --git a/window_qt.py b/window_qt.py index 4ef9064..6c99a6e 100755 --- a/window_qt.py +++ b/window_qt.py @@ -40,16 +40,19 @@ class MainWindow(QMainWindow): print('Click left') if event.button() == Qt.RightButton: print('Click right') + else: + if event.button() == Qt.RightButton: + print('Click long right') self.click_event_time = 0 self.v_pet.activity.is_interacting_with_user = False def mouseMoveEvent(self, event): - self.click_event_time = 0 if event.buttons() == Qt.LeftButton: delta = event.globalPos() - self.drag_position self.move(self.pos() + delta) self.drag_position = event.globalPos() + self.click_event_time = 0 def draw(self, img): img = img.rotate(Rotate.up)