Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGary Martin <gary@garycmartin.com>2010-06-17 03:56:37 (GMT)
committer Gary Martin <gary@garycmartin.com>2010-06-17 03:56:37 (GMT)
commit9167e5a85dc90b86f593eab2860735e79955c88d (patch)
treeedb53f66ceebe473e0b152fa5977fcbb75773e9d
parentf31c9e46eb51fdd967acb2bf27cf11bfb4b13231 (diff)
Fixed a conflict case I missed.
-rw-r--r--tools.py52
1 files changed, 25 insertions, 27 deletions
diff --git a/tools.py b/tools.py
index 196dfe2..e20f93f 100644
--- a/tools.py
+++ b/tools.py
@@ -322,37 +322,35 @@ class GrabTool(Tool):
self._current_body = None
def handleToolEvent(self,event):
- #look for default events, and if none are handled then try the custom events
- if not super(GrabTool,self).handleEvents(event):
- # we handle two types of "grab" depending on simulation running or not
- if event.type == MOUSEBUTTONDOWN:
- if event.button == 1:
- # grab the first object at the mouse pointer
- bodylist = self.game.world.get_bodies_at_pos(event.pos, include_static=False)
- if bodylist and len(bodylist) > 0:
- if self.game.world.run_physics:
- self.game.world.add.mouseJoint(bodylist[0], event.pos)
- else:
- self._current_body = bodylist[0]
- elif event.type == MOUSEBUTTONUP:
- # let it go
- if event.button == 1:
+ # we handle two types of "grab" depending on simulation running or not
+ if event.type == MOUSEBUTTONDOWN:
+ if event.button == 1:
+ # grab the first object at the mouse pointer
+ bodylist = self.game.world.get_bodies_at_pos(event.pos, include_static=False)
+ if bodylist and len(bodylist) > 0:
if self.game.world.run_physics:
- self.game.world.add.remove_mouseJoint()
+ self.game.world.add.mouseJoint(bodylist[0], event.pos)
else:
- self._current_body = None
- elif event.type == MOUSEMOTION and event.buttons[0]:
- # move it around
+ self._current_body = bodylist[0]
+ elif event.type == MOUSEBUTTONUP:
+ # let it go
+ if event.button == 1:
if self.game.world.run_physics:
- # use box2D mouse motion
- self.game.world.mouse_move(event.pos)
+ self.game.world.add.remove_mouseJoint()
else:
- # position directly (if we have a current body)
- if self._current_body is not None:
- x, y = self.game.world.to_world(event.pos)
- x /= self.game.world.ppm
- y /= self.game.world.ppm
- self._current_body.position = (x, y)
+ self._current_body = None
+ elif event.type == MOUSEMOTION and event.buttons[0]:
+ # move it around
+ if self.game.world.run_physics:
+ # use box2D mouse motion
+ self.game.world.mouse_move(event.pos)
+ else:
+ # position directly (if we have a current body)
+ if self._current_body is not None:
+ x, y = self.game.world.to_world(event.pos)
+ x /= self.game.world.ppm
+ y /= self.game.world.ppm
+ self._current_body.position = (x, y)
def cancel(self):
self.game.world.add.remove_mouseJoint()