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)
|
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;
|
local func = ClassName.new or ClassName.New or ClassName.__new;
|
||||||
if ClassName.__noSetup then -- if is support initing props
|
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
|
for iprop = props.n,1,-1 do
|
||||||
local prop = props[iprop];
|
local prop = props[iprop];
|
||||||
if prop then
|
if prop then
|
||||||
for i,v in pairs(prop) do
|
for i,v in pairs(prop) do
|
||||||
if type(i) == "number" then
|
if type(i) == "number" then
|
||||||
childs[i] = ((iprop == 1) and v or v:Clone());
|
childs[i] = ((iprop == 1) and v or v:Clone());
|
||||||
|
elseif bind(i) then
|
||||||
|
binds[i] = v;
|
||||||
else
|
else
|
||||||
parsed[i] = v;
|
parsed[i] = v;
|
||||||
end
|
end
|
||||||
|
|
@ -72,6 +74,9 @@ function module.init(shared)
|
||||||
for _,v in ipairs(childs) do
|
for _,v in ipairs(childs) do
|
||||||
mountf(item,v,holder);
|
mountf(item,v,holder);
|
||||||
end
|
end
|
||||||
|
for i,v in pairs(binds) do
|
||||||
|
bind(item,i,v);
|
||||||
|
end
|
||||||
return item;
|
return item;
|
||||||
end
|
end
|
||||||
item = func();
|
item = func();
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,11 @@ function module.init(shared)
|
||||||
|
|
||||||
-- try binding, if key dose match with anything, ignore call
|
-- try binding, if key dose match with anything, ignore call
|
||||||
function new.bind(this,key,func,typefunc)
|
function new.bind(this,key,func,typefunc)
|
||||||
|
if not key then
|
||||||
|
key = this;
|
||||||
|
this = nil;
|
||||||
|
end
|
||||||
|
|
||||||
-- if is advanced binding (self setted)
|
-- if is advanced binding (self setted)
|
||||||
typefunc = typefunc or type(func);
|
typefunc = typefunc or type(func);
|
||||||
local self;
|
local self;
|
||||||
|
|
@ -39,8 +44,6 @@ function module.init(shared)
|
||||||
-- check prefix
|
-- check prefix
|
||||||
if key:sub(1,prefixLen) ~= prefix then
|
if key:sub(1,prefixLen) ~= prefix then
|
||||||
return;
|
return;
|
||||||
elseif not func then
|
|
||||||
return true; -- nil binding
|
|
||||||
end
|
end
|
||||||
key = key:sub(prefixLen + 1,-1);
|
key = key:sub(prefixLen + 1,-1);
|
||||||
|
|
||||||
|
|
@ -48,18 +51,24 @@ function module.init(shared)
|
||||||
for specKey,specFunc in pairs(special) do
|
for specKey,specFunc in pairs(special) do
|
||||||
local find = {key:match(specKey)};
|
local find = {key:match(specKey)};
|
||||||
if #find ~= 0 then
|
if #find ~= 0 then
|
||||||
specFunc(this,func,unpack(find));
|
if func then
|
||||||
|
specFunc(this,func,unpack(find));
|
||||||
|
end
|
||||||
return true;
|
return true;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- binding normal events
|
-- binding normal events
|
||||||
local event = this[key];
|
if this then
|
||||||
if event then
|
local event = this[key];
|
||||||
event:Connect(function(...)
|
if event then
|
||||||
func(self or this,...);
|
if func then
|
||||||
end);
|
event:Connect(function(...)
|
||||||
return true;
|
func(self or this,...);
|
||||||
|
end);
|
||||||
|
end
|
||||||
|
return true;
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ function module.RunTween(Item,Data,Properties,Ended)
|
||||||
local CallBack = Data.CallBack
|
local CallBack = Data.CallBack
|
||||||
if CallBack then
|
if CallBack then
|
||||||
for FncIndex,Fnc in pairs(CallBack) do
|
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
|
CallBack[FncIndex] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -214,7 +214,7 @@ function module.RunTween(Item,Data,Properties,Ended)
|
||||||
CallBack[FncIndex] = nil
|
CallBack[FncIndex] = nil
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local alphaNum = tonumber(FncIndex:match"~(%d+)")
|
local alphaNum = tonumber(FncIndex:match"~([%d.]+)")
|
||||||
if alphaNum <= Alpha then
|
if alphaNum <= Alpha then
|
||||||
Fnc(Index)
|
Fnc(Index)
|
||||||
CallBack[FncIndex] = nil
|
CallBack[FncIndex] = nil
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue