PageRenderTime 76ms CodeModel.GetById 40ms app.highlight 13ms RepoModel.GetById 17ms app.codeStats 0ms

/script_binding/lua/demo_button.lua

http://ftk.googlecode.com/
Lua | 70 lines | 53 code | 17 blank | 0 comment | 0 complexity | 3ae0f9224855c3f4bdcc4ad6c819bbb6 MD5 | raw file
 1function OnQuit(button)
 2	print("OnQuit: " .. button:GetText())
 3	Ftk.Quit()
 4
 5	return RET_OK
 6end
 7
 8function OnHide(button)
 9	print("OnHide: " .. button:GetText())
10	button:Toplevel():Lookup(100):Show(0)
11	return RET_OK
12end
13
14function OnShow(button)
15	print("OnShow: " .. button:GetText())
16	button:Toplevel():Lookup(100):Show(1)
17	return RET_OK
18end
19
20function OnClicked(button)
21	print("OnShow: " .. button:GetText())
22	print("Clicked")
23	return RET_OK
24end
25
26function AppInit()
27	win=FtkAppWindow.Create()
28	win:SetText("Demo button")
29	win:SetAttr(FTK_ATTR_QUIT_WHEN_CLOSE)
30	
31	width=win:Width()
32	height=win:Height()
33
34	width = width/3 - 10;
35	button=FtkButton.Create(win, 0, 30, width, 50)
36	button:SetText("show")
37	button:SetClickedListener("OnShow")
38
39	button=FtkButton.Create(win, width + 10, 30, width, 50);
40	button:SetText("hide")
41	button:SetClickedListener("OnHide")
42
43	button=FtkButton.Create(win, 2*(width + 10), 30, width, 50)
44	button:SetText("????");
45	button:SetId(100)
46	button:SetClickedListener("OnClicked")
47
48	button=FtkButton.Create(win, 0, 130, width, 40);
49	button:SetClickedListener("OnClicked")
50
51	button:SetText("yes")
52	button:SetClickedListener("OnClicked")
53
54	button=FtkButton.Create(win, 2*(width + 10), 130, width, 40);
55	button:SetText("no")
56
57	button=FtkButton.Create(win, width + 10, height/2, width, 60);
58	button:SetText("Quit")
59	button:SetClickedListener("OnQuit")
60
61	win:SetFocus(button)
62	win:ShowAll(1)
63
64	return 1
65end
66
67Ftk.Init(1, {"demo button"})
68AppInit()
69Ftk.Run()
70