-
-
Notifications
You must be signed in to change notification settings - Fork 17
Click
windwp edited this page May 22, 2022
·
4 revisions
basic.click_test = {
text = function ()
return "Click me"
end,
click = function ()
print("Do click")
end
}
you need to wrap it on function make_click and choose a unique name.
local windline = require('windline')
local language = 'EN'
local click_change_language = windline.make_click('change_language', function()
language = language == 'EN' and 'US' or 'EN'
end)
basic.language = {
text = function()
return {
{ 'LANG: ', '' },
{
language,
'',
click_change_language,
},
}
end,
}
or you can do this
local windline = require('windline')
local language = 'EN'
basic.language = {
text = function()
return {
{ 'LANG: ', '' },
{
language,
'',
windline.make_click('change_language', function()
language = language == 'EN' and 'US' or 'EN'
end),
},
}
end,
}
the first version have better performance. it reduce the complex of text
function because child component is create on runtime .