-
Notifications
You must be signed in to change notification settings - Fork 11
Examples: Button
William Willing edited this page Jan 11, 2015
·
12 revisions
Creating a button
require "gui"
local window = gui.create_window()
window.title = "Button Demo"
local button = window:add_button()
button.x = 10
button.y = 10
button.text = "OK"
gui.run()Responding to a button click
require "gui"
local window = gui.create_window()
window.title = "Click Demo"
local button = window:add_button()
button.x = 10
button.y = 10
button.text = "OK"
function button:on_click()
button.text = "You clicked?"
end
gui.run()Changing the alignment of text on a button v4
require "gui"
local window = gui.create_window()
window.title = "Alignment Demo"
local button = window:add_button()
button.text = "Hello"
button.height = 100
button.alignment = "bottom left"
gui.run()Enabling word wrap v3
require "gui"
local window = gui.create_window()
window.title = "Word Wrap Demo"
local button = window:add_button()
button.text = "This text is too long to fit on one line, but who cares!"
button.width = 100
button.height = 100
button.word_wrap = true
function button:on_click()
button.word_wrap = not button.word_wrap
end
gui.run()Destroying a button v3
require "gui"
local window = gui.create_window()
window.title = "Destroy Demo"
local button = window:add_button()
button.text = "Destroy!"
function button:on_click()
button:destroy()
end
gui.run()