PageRenderTime 7ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/script_binding/lua/demo_menu.lua

http://ftk.googlecode.com/
Lua | 47 lines | 35 code | 12 blank | 0 comment | 0 complexity | 2fcf5fbc031ccec6b249f65a3ea92fdf MD5 | raw file
 1function OnSave(item)
 2	print("OnSave: " .. item:GetText())
 3	return RET_OK
 4end
 5
 6function OnQuit(item)
 7	print("OnQuit: " .. item:GetText())
 8	Ftk.Quit()
 9
10	return RET_OK
11end
12
13function OnPrepareOptionMenu(menu_panel)
14	item = FtkMenuItem.Create(menu_panel)
15	item:Show(1)
16	item:SetText("Quit")
17	item:SetClickedListener("OnQuit")
18	
19	item = FtkMenuItem.Create(menu_panel)
20	item:Show(1)
21	item:SetText("Save")
22	item:SetClickedListener("OnSave")
23
24	return RET_OK;
25end
26
27function AppInit()
28	win=FtkAppWindow.Create()
29	win:SetAttr(FTK_ATTR_QUIT_WHEN_CLOSE)
30	win:SetText("Demo menu")
31
32	width=win:Width()
33	height=win:Height()
34	
35	label=FtkLabel.Create(win, 10, height/2, width-20, 30)
36	label:SetText("press F2 to open menu")
37
38	win:SetOnPrepareOptionsMenu("OnPrepareOptionMenu")
39	win:ShowAll(1)
40
41	return 1
42end
43
44Ftk.Init(1, {"menu"})
45AppInit()
46Ftk.Run()
47