|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
-- ==================================================================================
-- Input Handlers - All input handlers (mouse down, mouse click, mouse enter, etc) work in the same manner. For each handler,
-- a table of slot types is maintained. When an input event happens, if an entry matching the interacted slot type exists, the
-- functions listed within that entry are executed in the listed order. However, upon the first function returning true, execution
-- stops.
-- ==================================================================================
--convenience function to execute handlers
local handlers = handlerTable[slot.slotType]
if(not handlers) then return end
for i = 1,#handlers do
local done, returnVal = handlers[i](slot, ...)
--terminate on the first handler that returns something that's not false or nil
if(done) then
return done, returnVal
end
end
return false
end
local handlers = handlerTable[slot.slotType]
if(not handlers) then
return
end
local buttonHandlers = handlers[buttonId]
if(not buttonHandlers) then return end
for i = 1,#buttonHandlers do
local done, returnVal = buttonHandlers[i](slot, ...)
--terminate on the first handler that returns something that's not false or nil
if(done) then
return done, returnVal
end
end
return false
end |