| 4 | |
| 5 | {{{#!lua |
| 6 | -- some_name.ui.lua |
| 7 | |
| 8 | register_ui "mywindow" |
| 9 | { |
| 10 | element "window" { -- id will be mywindow.window |
| 11 | position = { 10, 10 }, |
| 12 | dimension = { 400, 100 }, |
| 13 | class = "mywindow", -- style class |
| 14 | element { -- unnamed element (mywindow.window.1) |
| 15 | position = { 10, 10 }, -- relative, dimension auto |
| 16 | text = "Hello world! Fine day?", |
| 17 | }, |
| 18 | button "yes" { -- subelement, will be mywindow.window.yes |
| 19 | rposition = { 0.1, 0.8 }, -- relative positioning |
| 20 | rdimension = { 0.3, nil }, -- just one value, other is nil |
| 21 | dimension = { nil, 20 }, -- other value not relative |
| 22 | text = "Yes!", |
| 23 | }, |
| 24 | button "no" { -- |
| 25 | rposition = { 0.1, 0.8 }, -- relative positioning |
| 26 | rdimension = { 0.3 }, -- just one value, other is nil hence can be ommited |
| 27 | dimension = { nil, 20 }, -- other value not relative |
| 28 | text = "No :(", |
| 29 | }, |
| 30 | }, |
| 31 | } |
| 32 | |
| 33 | }}} |
| 34 | |
| 35 | {{{ |
| 36 | -- some_script.lua |
| 37 | |
| 38 | ui_element = ui.create( "mywindow" ); |
| 39 | local result |
| 40 | ui_element:find("yes").on_click = function(self) result = true; self:destroy() end |
| 41 | ui_element:find("no").on_click = function(self) result = false; self:destroy() end |
| 42 | ui:run_modal( ui_element ) |
| 43 | |
| 44 | }}} |
| 45 | |