The width property represent the width of the client area of the window, excluding the left and right borders
Window.width read/write property
Get or set the Window's width. The width starts from 0 (left side of the Window) and increase to the right direction.
Example
local ui = require "ui"
-- create a simple window
local win = ui.Window("Window.height sample", 320, 200)
local label = ui.Label(win, "")
local start_btn = ui.Button(win, "Grows it !", 70, 50)
local stop_btn = ui.Button(win, "Stop", start_btn.x+100, start_btn.y)
local growing = true
local function onClick()
growing = not growing
stop_btn.enabled = growing == true
start_btn.enabled = growing == false
end
function win:onResize()
win:status("Window height : "..win.height)
end
start_btn.onClick = onClick
stop_btn.onClick = onClick
-- update status bar
win:onResize()
-- update buttons
onClick()
-- Keep increasing Window with
async(function()
while(true) do
if growing then
win.width = win.width + 1
end
sleep(10)
end
end)
ui.run(win):wait()