Install a moduli(5) manual page.
[dragonfly.git] / contrib / bsdinstaller-1.1.6 / src / backend / lua / scripts / test / menu.lua
1 -- test/menu.lua
2 -- $Id: menu.lua,v 1.5 2004/11/26 04:28:10 cpressey Exp $
3 -- Test of the DFUI Menu abstraction wrapper thing.
4
5 require "dfui"
6
7 local c = DFUIConnection.new("tcp", "9999")
8 c:start()
9
10 local done = false
11
12 -- manually create a menu,
13 -- manually populate it with items, and
14 -- manually present it:
15
16 menu = Menu.new(c, {
17     name = "My Menu",
18     short_desc = "This is my menu."
19 })
20
21 menu:add_item{
22     name = "First Thing",
23     short_desc = "This is the first thing",
24     effect = function()
25         print("This is the 1st thing.")
26     end
27 }
28
29 menu:add_item{
30     name = "Second Thing",
31     short_desc = "This is the second thing",
32     effect = function()
33         print("This is the 2nd thing.")
34     end
35 }
36
37 menu:add_item{
38     name = "Third Thing",
39     short_desc = "This is the third thing",
40     effect = function()
41         print("This is the 3rd thing.")
42     end
43 }
44
45 -- Manually create and add a submenu
46
47 submenu = Menu.new(c, {
48    name = "My Submenu",
49    short_desc = "This is a submenu"
50 })
51
52 submenu:add_item{
53     name = "Foo",
54     effect = function() print("foo!") end
55 }
56 submenu:add_item{
57     name = "Bar",
58     effect = function() print("bar!") end
59 }
60
61 menu:add_item{
62     name = "Submenu",
63     short_desc = "This item leads to a submenu",
64     effect = function()
65         submenu:present()
66     end
67 }
68
69 menu:add_item{
70     name = "Stop",
71     short_desc = "OK, enough of this",
72     effect = function()
73         done = true
74     end
75 }
76
77 while not done do
78         menu:present()
79 end