Skip to content
Snippets Groups Projects
Commit 0e64a847 authored by dg's avatar dg
Browse files

fix

git-svn-id: http://svn.net-core.org/repos/t-engine4@4188 51575b47-30f0-44d4-a5cc-537603b46e54
parent 1c38b1da
No related branches found
No related tags found
No related merge requests found
......@@ -52,12 +52,18 @@ function _M:receiveMouse(button, x, y, isup, force_name, extra)
end
function _M:receiveMouseMotion(button, x, y, xrel, yrel, force_name, extra)
local cur_m = nil
for i, m in ipairs(self.areas) do
if (not m.mode or m.mode.move) and (x >= m.x1 and x < m.x2 and y >= m.y1 and y < m.y2) and (not force_name or force_name == m.name) then
m.fct(button, x, y, xrel, yrel, x-m.x1, y-m.y1, "motion", extra)
cur_m = m
break
end
end
if self.last_m and self.last_m.allow_out_events and self.last_m ~= cur_m then
self.last_m.fct("none", x, y, xrel, yrel, x-self.last_m.x1, y-self.last_m.y1, "out", extra)
end
self.last_m = cur_m
end
--- Delegate an event from an other mouse handler
......@@ -80,13 +86,13 @@ function _M:setCurrent()
end
--- Registers a click zone that when clicked will call the object's "onClick" method
function _M:registerZone(x, y, w, h, fct, mode, name)
table.insert(self.areas, 1, {x1=x,y1=y,x2=x+w,y2=y+h, fct=fct, mode=mode, name=name})
function _M:registerZone(x, y, w, h, fct, mode, name, allow_out_events)
table.insert(self.areas, 1, {x1=x,y1=y,x2=x+w,y2=y+h, fct=fct, mode=mode, name=name, allow_out_events=allow_out_events})
end
function _M:registerZones(t)
for i, z in ipairs(t) do
self:registerZone(z.x, z.y, z.w, z.h, z.fct, z.mode, z.name)
self:registerZone(z.x, z.y, z.w, z.h, z.fct, z.mode, z.name, z.out_events)
end
end
......
......@@ -1446,6 +1446,7 @@ function _M:setupMouse(reset)
-- Use hotkeys with mouse
self.mouse:registerZone(self.hotkeys_display.display_x, self.hotkeys_display.display_y, self.w, self.h, function(button, mx, my, xrel, yrel, bx, by, event)
if self.show_npc_list then return end
if event == "out" then self.hotkeys_display.cur_sel = nil return end
if event == "button" and button == "left" and ((self.zone and self.zone.wilderness) or (self.key ~= self.normal_key)) then return end
self.hotkeys_display:onMouse(button, mx, my, event == "button",
function(text)
......@@ -1461,7 +1462,7 @@ function _M:setupMouse(reset)
end
end
)
end)
end, nil, "hotkeys", true)
-- Use icons
self.mouse:registerZone(self.icons.display_x, self.icons.display_y, self.icons.w, self.icons.h, function(button, mx, my, xrel, yrel, bx, by)
self:mouseIcon(bx, by)
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment