From 05022304fbd8132d63cb909f0507a107da216485 Mon Sep 17 00:00:00 2001 From: Brian Caine Date: Mon, 26 Nov 2007 09:27:25 -0500 Subject: [PATCH] Fixed a little GUI error. When you click a widget, it sends a MOUSEBUTTONDOWN. And when you release it, it sends a MOUSEBUTTONUP. Well, if you clicked the widget and moved the mouse off of it, it stays down. This commit fixed it. Not that big of a deal. Just a few lines. --- pygame_gui/DerGUI.py | 15 ++++++++++++--- update_zip.sh | 6 +++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/pygame_gui/DerGUI.py b/pygame_gui/DerGUI.py index d8b9b5e..3c59c13 100644 --- a/pygame_gui/DerGUI.py +++ b/pygame_gui/DerGUI.py @@ -53,6 +53,8 @@ class GUISystem: self.keys = {} self.last_time = -1 + self.hit = 0 + def parse_gui_def(self, gui_def): results = {} @@ -214,11 +216,18 @@ class GUISystem: for widget in self.widgets: widget_rect = widget.getRect() - if widget_rect.collidepoint(new_event['data']['pos']): - if new_event['type'] != 'MOUSEMOTION' and widget.is_visible(): - self.focus = widget + if new_event['type'] != 'MOUSEBUTTONUP': + if widget_rect.collidepoint(new_event['data']['pos']): + if new_event['type'] != 'MOUSEMOTION' and widget.is_visible(): + self.focus = widget + self.focus.event(new_event) + count += 1 + self.hit = 1 + else: + if self.hit: self.focus.event(new_event) count += 1 + self.hit = 0 else: if new_event['type'] == 'KEYDOWN': self.keys[new_event['data']['key']] = new_event['data'] diff --git a/update_zip.sh b/update_zip.sh index 92c3a5b..1e68792 100755 --- a/update_zip.sh +++ b/update_zip.sh @@ -8,8 +8,8 @@ cd .. #zip ../pack/sample_pack_contents.zip ./* #cd .. -cd a_map/ -zip -r ../pack/a_map.zip ./* -cd .. +#cd a_map/ +#zip -r ../pack/a_map.zip ./* +#cd .. # end -- 2.11.4.GIT