Skip to content

Examples: Dialog

William Willing edited this page Jan 10, 2015 · 4 revisions

Creating a modeless dialog box

require "gui"

local window = gui.create_window()
window.title = "Modeless Dialog Demo"
    
local dialog = window:create_dialog()
dialog.title = "Modeless Dialog"
dialog:show_modeless()
    
gui.run()

Creating a modal dialog box

require "gui"

local window = gui.create_window()
window.title = "Modal Dialog Demo"
    
local dialog = window:create_dialog()
dialog.title = "Modal Dialog"
dialog:show_modal()
    
gui.run()

Adding a button to a dialog box

require "gui"

local window = gui.create_window()
window.title = "Button Dialog Demo"
    
local dialog = window:create_dialog()
dialog.title = "Button Dialog"
    
local button = dialog:add_button()
button.text = "Close"
    
function button:on_click()
  dialog:close()
end
    
dialog:show_modal()
    
gui.run()

Preventing a dialog box from closing v4

require 'gui'

local window = gui.create_window()
window.title = "Close Demo"

local dialog = window:create_dialog()
function dialog:on_closing()
  return false
end

dialog:show_modeless()

gui.run()

Clone this wiki locally