Files
Basalt/Basalt/libraries/basaltEvent.lua
Robert Jelic bb1b1beb79 Basalt 1.7 Update
- New Objects (Flexbox, Graph, Treeview)
- Pluginsystem to add/remove functionality
- Reworked the entire Object system, instead of one big Object Class we have multiple classes: Object, VisualObject, ChangeableObject
- Instead of one big Frame Class we have multiple Frame Classes: BaseFrame, Frame, MovableFrame, ScrollableFrame, MonitorFrame, Flexbox
- Removed the Animation Object, and added a animation plugin instead
- Removed the Graphic Object and merged it's functionality with the image object
- Updated currently existing objects
2023-04-30 17:05:34 +02:00

55 lines
1.4 KiB
Lua

return function()
local events = {}
local event = {
registerEvent = function(self, _event, func)
if (events[_event] == nil) then
events[_event] = {}
end
table.insert(events[_event], func)
end,
removeEvent = function(self, _event, index)
events[_event][index[_event]] = nil
end,
hasEvent = function(self, _event)
return events[_event]~=nil
end,
getEventCount = function(self, _event)
return events[_event]~=nil and #events[_event] or 0
end,
getEvents = function(self)
local t = {}
for k,v in pairs(events)do
table.insert(t, k)
end
return t
end,
clearEvent = function(self, _event)
events[_event] = nil
end,
clear = function(self, _event)
events = {}
end,
sendEvent = function(self, _event, ...)
local returnValue
if (events[_event] ~= nil) then
for _, value in pairs(events[_event]) do
local val = value(...)
if(val==false)then
returnValue = val
end
end
end
return returnValue
end,
}
event.__index = event
return event
end