mirror of
https://github.com/keharriso/love-nuklear.git
synced 2025-09-10 16:17:47 -04:00
Add closure alternatives to begin/end pairs
This commit is contained in:
parent
bb3ffeb957
commit
976ff9f63b
3 changed files with 413 additions and 52 deletions
51
example/closure.lua
Normal file
51
example/closure.lua
Normal file
|
@ -0,0 +1,51 @@
|
|||
-- Show off the optional closure-oriented versions of basic functions
|
||||
|
||||
local function menu(ui)
|
||||
ui:layoutRow('dynamic', 30, 2)
|
||||
ui:menu('Menu A', nil, 100, 200, function ()
|
||||
ui:layoutRow('dynamic', 30, 1)
|
||||
if ui:menuItem('Item 1') then
|
||||
print 'Closure: Item 1'
|
||||
end
|
||||
if ui:menuItem('Item 2') then
|
||||
print 'Closure: Item 2'
|
||||
end
|
||||
end)
|
||||
ui:menu('Menu B', nil, 100, 200, function ()
|
||||
ui:layoutRow('dynamic', 30, 1)
|
||||
if ui:menuItem('Item 3') then
|
||||
print 'Closure: Item 3'
|
||||
end
|
||||
if ui:menuItem('Item 4') then
|
||||
print 'Closure: Item 4'
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local comboText = 'Combo 1'
|
||||
|
||||
function combo(ui)
|
||||
ui:layoutRow('dynamic', 30, 1)
|
||||
if ui:comboboxItem('Combo 1') then
|
||||
print 'Closure: Combo 1'
|
||||
comboText = 'Combo 1'
|
||||
end
|
||||
if ui:comboboxItem('Combo 2') then
|
||||
print 'Closure: Combo 2'
|
||||
comboText = 'Combo 2'
|
||||
end
|
||||
if ui:comboboxItem('Combo 3') then
|
||||
print 'Closure: Combo 3'
|
||||
comboText = 'Combo 3'
|
||||
end
|
||||
end
|
||||
|
||||
local function window(ui)
|
||||
ui:menubar(menu)
|
||||
ui:layoutRow('dynamic', 30, 1)
|
||||
ui:combobox(comboText, combo)
|
||||
end
|
||||
|
||||
return function (ui)
|
||||
ui:window('Closure', 200, 200, 150, 120, {'title', 'movable', 'border'}, window)
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue