From 6d93362ebb4def3109d194818b2ab5c0081805ad Mon Sep 17 00:00:00 2001 From: Pixel Date: Tue, 15 Dec 2009 14:09:53 -0800 Subject: Fixing panning. --- dalos.lua | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'dalos.lua') diff --git a/dalos.lua b/dalos.lua index b7f58a0..5f153bc 100644 --- a/dalos.lua +++ b/dalos.lua @@ -33,8 +33,8 @@ dalosp.canvas = { findobj = function (self, x, y) local obj, ind - x = x + 0 - y = y + 0 + x = x - self.origin.x + y = y - self.origin.y for k, v in ipairs(self.objects) do if v.x <= x and (v.x + v.w) >= x and v.y <= y and (v.y + v.h) >= y then @@ -66,12 +66,11 @@ dalosp.canvas = { motion_cb = function (self, x, y, status) if self.stateful.panning then - print "Panning..." local ox, oy = self.ox, self.oy local dx, dy = x - ox, y - oy self:panning(dx, dy) self.ox, self.oy = x, y - elseif iup.isbutton1(status) then + elseif self.stateful.leftbutton then if self.stateful.leftclk and not self.stateful.linking then self.stateful.linking = self.stateful.leftclk end local linking = self.stateful.linking if linking then @@ -79,7 +78,7 @@ dalosp.canvas = { else -- start selection square ? end - elseif iup.isbutton3(status) then + elseif self.stateful.rghtbutton then if self.stateful.rghtclk and not self.stateful.moving then self.stateful.moving = self.stateful.rghtclk end local moving = self.stateful.moving if moving then @@ -97,7 +96,7 @@ dalosp.canvas = { if button == iup.BUTTON1 or not button then if pressed == 1 then self.stateful.leftbutton = true - if self.stateful.rghtclk then + if self.stateful.rghtbutton then self.stateful.panning = true else self.stateful.leftclk = self:findobj(x,y) @@ -118,7 +117,7 @@ dalosp.canvas = { if button == iup.BUTTON3 or not button then if pressed == 1 then self.stateful.rghtbutton = true - if self.stateful.leftclk then + if self.stateful.leftbutton then self.stateful.panning = true else self.stateful.rghtclk = self:findobj(x, y) -- cgit v1.2.3