summaryrefslogtreecommitdiff
path: root/reference/csharp/ui/src/focus_main.cs
diff options
context:
space:
mode:
Diffstat (limited to 'reference/csharp/ui/src/focus_main.cs')
-rw-r--r--reference/csharp/ui/src/focus_main.cs69
1 files changed, 32 insertions, 37 deletions
diff --git a/reference/csharp/ui/src/focus_main.cs b/reference/csharp/ui/src/focus_main.cs
index 5cf6463..700172f 100644
--- a/reference/csharp/ui/src/focus_main.cs
+++ b/reference/csharp/ui/src/focus_main.cs
@@ -16,62 +16,57 @@ public class Example
16 Efl.All.Init(Efl.Components.Ui); 16 Efl.All.Init(Efl.Components.Ui);
17 17
18 // Create a window and initialize it 18 // Create a window and initialize it
19 var win = new Efl.Ui.Win(null, (Efl.Ui.Win ewin) => { 19 var win = new Efl.Ui.Win(null);
20 ewin.SetWinType(Efl.Ui.WinType.Basic); 20 win.SetWinType(Efl.Ui.WinType.Basic);
21 ewin.SetText("Focus example"); 21 win.SetText("Focus example");
22 ewin.SetAutohide(true); 22 win.SetAutohide(true);
23 ewin.HideEvt += (object sender, EventArgs e) => { 23 win.HideEvt += (object sender, EventArgs e) => {
24 // Exit the EFL main loop 24 // Exit the EFL main loop
25 Efl.Ui.Config.Exit(); 25 Efl.Ui.Config.Exit();
26 }; 26 };
27 }); 27
28 28
29 // Create the main box container 29 // Create the main box container
30 var vbox = new Efl.Ui.Box(win, (Efl.Ui.Box ebox) => { 30 var vbox = new Efl.Ui.Box(win);
31 ebox.SetHintMin(new Eina.Size2D(360, 240)); 31 vbox.SetHintMin(new Eina.Size2D(360, 240));
32 win.SetContent(ebox); 32 win.SetContent(vbox);
33 });
34 33
35 // Create some check boxes 34 // Create some check boxes
36 Efl.Ui.Check first_checkbox = null; 35 Efl.Ui.Check first_checkbox = null;
37 for (int i = 0; i< 5; i++) { 36 for (int i = 0; i< 5; i++) {
38 var checkbox = new Efl.Ui.Check(vbox, (Efl.Ui.Check echeck) => { 37 var checkbox = new Efl.Ui.Check(vbox);
39 echeck.SetText("Check " + i); 38 checkbox.SetText("Check " + i);
40 echeck.SetHintAlign(0.5, 0.5); 39 checkbox.SetHintAlign(0.5, 0.5);
41 echeck.FocusChangedEvt += FocusChangedCb; 40 checkbox.FocusChangedEvt += FocusChangedCb;
42 vbox.DoPack(echeck); 41 vbox.DoPack(checkbox);
43 });
44 if (i == 0) first_checkbox = checkbox; 42 if (i == 0) first_checkbox = checkbox;
45 }; 43 };
46 44
47 // Create an horizontal box to contain the two buttons 45 // Create an horizontal box to contain the two buttons
48 var hbox = new Efl.Ui.Box(vbox, (Efl.Ui.Box ebox) => { 46 var hbox = new Efl.Ui.Box(vbox);
49 ebox.SetDirection(Efl.Ui.Dir.Horizontal); 47 hbox.SetDirection(Efl.Ui.Dir.Horizontal);
50 vbox.DoPack(ebox); 48 vbox.DoPack(hbox);
51 });
52 49
53 // Create a "Focus Mover" button 50 // Create a "Focus Mover" button
54 new Efl.Ui.Button(hbox, (Efl.Ui.Button ebutton) => { 51 var button = new Efl.Ui.Button(hbox);
55 ebutton.SetText("Focus mover"); 52 button.SetText("Focus mover");
56 ebutton.FocusChangedEvt += FocusChangedCb; 53 button.FocusChangedEvt += FocusChangedCb;
57 ebutton.ClickedEvt += (object sender, EventArgs e) => { 54 button.ClickedEvt += (object sender, EventArgs e) => {
58 Console.WriteLine("Clicked Focus Mover"); 55 Console.WriteLine("Clicked Focus Mover");
59 // Manually transfer focus to the first check box 56 // Manually transfer focus to the first check box
60 Efl.Ui.Focus.Util.Focus(first_checkbox); 57 Efl.Ui.Focus.Util.Focus(first_checkbox);
61 }; 58 };
62 hbox.DoPack(ebutton); 59 hbox.DoPack(button);
63 });
64 60
65 // Create a Quit button 61 // Create a Quit button
66 new Efl.Ui.Button(hbox, (Efl.Ui.Button ebutton) => { 62 button = new Efl.Ui.Button(hbox);
67 ebutton.SetText("Quit"); 63 button.SetText("Quit");
68 ebutton.FocusChangedEvt += FocusChangedCb; 64 button.FocusChangedEvt += FocusChangedCb;
69 ebutton.ClickedEvt += (object sender, EventArgs e) => { 65 button.ClickedEvt += (object sender, EventArgs e) => {
70 Console.WriteLine("Clicked Quit"); 66 Console.WriteLine("Clicked Quit");
71 Efl.Ui.Config.Exit(); 67 Efl.Ui.Config.Exit();
72 }; 68 };
73 hbox.DoPack(ebutton); 69 hbox.DoPack(button);
74 });
75 70
76 // Show the focus highlight 71 // Show the focus highlight
77 win.SetFocusHighlightEnabled(true); 72 win.SetFocusHighlightEnabled(true);