Update XML events API
This commit is contained in:
@@ -167,6 +167,15 @@ local function registerFunctionEvent(self, data, event, renderContext)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function registerFunctionEvents(self, data, events, renderContext)
|
||||||
|
for _, event in pairs(events) do
|
||||||
|
local expression = data:reactiveProperties()[event]
|
||||||
|
if (expression ~= nil) then
|
||||||
|
registerFunctionEvent(self, expression .. "()", self[event], renderContext)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local currentEffect = nil
|
local currentEffect = nil
|
||||||
|
|
||||||
local clearEffectDependencies = function(effect)
|
local clearEffectDependencies = function(effect)
|
||||||
@@ -284,7 +293,6 @@ return {
|
|||||||
end
|
end
|
||||||
basalt.effect(update)
|
basalt.effect(update)
|
||||||
end
|
end
|
||||||
|
|
||||||
self:updateSpecifiedValuesByXMLData(data, {
|
self:updateSpecifiedValuesByXMLData(data, {
|
||||||
"x",
|
"x",
|
||||||
"y",
|
"y",
|
||||||
@@ -293,14 +301,23 @@ return {
|
|||||||
"background",
|
"background",
|
||||||
"foreground"
|
"foreground"
|
||||||
})
|
})
|
||||||
|
registerFunctionEvents(self, data, {
|
||||||
local events = {"onClick", "onClickUp", "onHover", "onScroll", "onDrag", "onKey", "onKeyUp", "onRelease", "onChar", "onGetFocus", "onLoseFocus", "onResize", "onReposition", "onEvent", "onLeave"}
|
"onClick",
|
||||||
for _,v in pairs(events)do
|
"onClickUp",
|
||||||
if(xmlValue(v, data)~=nil)then
|
"onHover",
|
||||||
registerFunctionEvent(self, xmlValue(v, data), self[v], renderContext)
|
"onScroll",
|
||||||
end
|
"onDrag",
|
||||||
end
|
"onKey",
|
||||||
|
"onKeyUp",
|
||||||
|
"onRelease",
|
||||||
|
"onChar",
|
||||||
|
"onGetFocus",
|
||||||
|
"onLoseFocus",
|
||||||
|
"onResize",
|
||||||
|
"onReposition",
|
||||||
|
"onEvent",
|
||||||
|
"onLeave"
|
||||||
|
}, renderContext)
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
@@ -322,9 +339,9 @@ return {
|
|||||||
self:updateSpecifiedValuesByXMLData(data, {
|
self:updateSpecifiedValuesByXMLData(data, {
|
||||||
"value"
|
"value"
|
||||||
})
|
})
|
||||||
if(xmlValue("onChange", data)~=nil)then
|
registerFunctionEvent(self, data, {
|
||||||
registerFunctionEvent(self, xmlValue("onChange", data), self.onChange, renderContext)
|
"onChange"
|
||||||
end
|
}, renderContext)
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
@@ -942,10 +959,9 @@ return {
|
|||||||
"start",
|
"start",
|
||||||
"time"
|
"time"
|
||||||
})
|
})
|
||||||
|
registerFunctionEvents(self, data, {
|
||||||
if(xmlValue("onCall", data)~=nil)then
|
"onCall"
|
||||||
registerFunctionEvent(self, xmlValue("onCall", data), self.onCall, renderContext)
|
}, renderContext)
|
||||||
end
|
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user