fixed event handler
This commit is contained in:
parent
983576e415
commit
e1ef8a5dda
3 changed files with 26 additions and 12 deletions
|
|
@ -54,13 +54,15 @@ function module.init(shared)
|
|||
elseif classOfClassName == "table" then -- if classname is a calss what is included new function, call it for making new object (object)
|
||||
local func = ClassName.new or ClassName.New or ClassName.__new;
|
||||
if ClassName.__noSetup then -- if is support initing props
|
||||
local childs,props,parsed = {},pack(...),{};
|
||||
local childs,props,parsed,binds = {},pack(...),{},{};
|
||||
for iprop = props.n,1,-1 do
|
||||
local prop = props[iprop];
|
||||
if prop then
|
||||
for i,v in pairs(prop) do
|
||||
if type(i) == "number" then
|
||||
childs[i] = ((iprop == 1) and v or v:Clone());
|
||||
elseif bind(i) then
|
||||
binds[i] = v;
|
||||
else
|
||||
parsed[i] = v;
|
||||
end
|
||||
|
|
@ -72,6 +74,9 @@ function module.init(shared)
|
|||
for _,v in ipairs(childs) do
|
||||
mountf(item,v,holder);
|
||||
end
|
||||
for i,v in pairs(binds) do
|
||||
bind(item,i,v);
|
||||
end
|
||||
return item;
|
||||
end
|
||||
item = func();
|
||||
|
|
|
|||
|
|
@ -29,6 +29,11 @@ function module.init(shared)
|
|||
|
||||
-- try binding, if key dose match with anything, ignore call
|
||||
function new.bind(this,key,func,typefunc)
|
||||
if not key then
|
||||
key = this;
|
||||
this = nil;
|
||||
end
|
||||
|
||||
-- if is advanced binding (self setted)
|
||||
typefunc = typefunc or type(func);
|
||||
local self;
|
||||
|
|
@ -39,8 +44,6 @@ function module.init(shared)
|
|||
-- check prefix
|
||||
if key:sub(1,prefixLen) ~= prefix then
|
||||
return;
|
||||
elseif not func then
|
||||
return true; -- nil binding
|
||||
end
|
||||
key = key:sub(prefixLen + 1,-1);
|
||||
|
||||
|
|
@ -48,18 +51,24 @@ function module.init(shared)
|
|||
for specKey,specFunc in pairs(special) do
|
||||
local find = {key:match(specKey)};
|
||||
if #find ~= 0 then
|
||||
specFunc(this,func,unpack(find));
|
||||
if func then
|
||||
specFunc(this,func,unpack(find));
|
||||
end
|
||||
return true;
|
||||
end
|
||||
end
|
||||
|
||||
-- binding normal events
|
||||
local event = this[key];
|
||||
if event then
|
||||
event:Connect(function(...)
|
||||
func(self or this,...);
|
||||
end);
|
||||
return true;
|
||||
if this then
|
||||
local event = this[key];
|
||||
if event then
|
||||
if func then
|
||||
event:Connect(function(...)
|
||||
func(self or this,...);
|
||||
end);
|
||||
end
|
||||
return true;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ function module.RunTween(Item,Data,Properties,Ended)
|
|||
local CallBack = Data.CallBack
|
||||
if CallBack then
|
||||
for FncIndex,Fnc in pairs(CallBack) do
|
||||
if type(Fnc) ~= "function" or type(tonumber(FncIndex)) ~= "number" then
|
||||
if type(Fnc) ~= "function" then
|
||||
CallBack[FncIndex] = nil
|
||||
end
|
||||
end
|
||||
|
|
@ -214,7 +214,7 @@ function module.RunTween(Item,Data,Properties,Ended)
|
|||
CallBack[FncIndex] = nil
|
||||
end
|
||||
else
|
||||
local alphaNum = tonumber(FncIndex:match"~(%d+)")
|
||||
local alphaNum = tonumber(FncIndex:match"~([%d.]+)")
|
||||
if alphaNum <= Alpha then
|
||||
Fnc(Index)
|
||||
CallBack[FncIndex] = nil
|
||||
|
|
|
|||
Loading…
Reference in a new issue