summaryrefslogtreecommitdiff
path: root/reference/csharp/ui
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2018-09-18 11:35:36 -0300
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2018-09-18 12:43:11 -0300
commitd1e530d25604d59a2e3f86ef59a5ecd47564800c (patch)
tree221a8e0ed31c9cca441b30648c57cf9554eebe70 /reference/csharp/ui
parentfce18f2ebe3dd22d817356594ee08dcd83cc3490 (diff)
Moved focus example to proper place
Summary: It is a guide, not a tutorial. Reviewers: vitor.sousa, lauromoura Reviewed By: vitor.sousa Differential Revision: https://phab.enlightenment.org/D7055
Diffstat (limited to 'reference/csharp/ui')
-rw-r--r--reference/csharp/ui/src/focus_main.cs69
-rw-r--r--reference/csharp/ui/src/meson.build7
2 files changed, 76 insertions, 0 deletions
diff --git a/reference/csharp/ui/src/focus_main.cs b/reference/csharp/ui/src/focus_main.cs
new file mode 100644
index 0000000..741acb4
--- /dev/null
+++ b/reference/csharp/ui/src/focus_main.cs
@@ -0,0 +1,69 @@
1using System;
2
3public class Example
4{
5 public static void QuitCb(object sender, EventArgs e)
6 {
7 Console.WriteLine("Clicked Quit");
8 efl.ui.Config.Exit();
9 }
10
11 public static void AboutCb(object sender, EventArgs e)
12 {
13 Console.WriteLine("Clicked About");
14 }
15
16 public static void FocusChangedCb(object sender, EventArgs e)
17 {
18 Console.WriteLine($"Focus for object {((efl.IText)sender).GetText()} changed to {((efl.ui.IWidget)sender).GetFocus()}");
19 }
20
21 public static void Main()
22 {
23 efl.All.Init(efl.Components.Ui);
24
25 efl.ui.IWin win = new efl.ui.Win(null, (efl.ui.IWin ewin) => {
26 ewin.SetWinType(efl.ui.Win_Type.Basic);
27 ewin.SetText("Hello World");
28 ewin.SetAutohide(true);
29 });
30 win.HideEvt += QuitCb;
31
32 efl.ui.IBox box = new efl.ui.Box(win);
33 eina.Size2D sz;
34 sz.W = 360;
35 sz.H = 240;
36 box.SetHintMin(sz);
37 win.SetContent(box);
38
39 efl.ui.IText text = new efl.ui.Text(box);
40 text.SetText("Label");
41 text.SetEditable(false);
42 text.FocusChangedEvt += FocusChangedCb;
43 box.DoPack(text);
44
45 efl.ui.IBox hbox = new efl.ui.Box(box);
46 hbox.SetDirection(efl.ui.Dir.Horizontal);
47 hbox.SetHintWeight(1.0, 0.1);
48 box.DoPack(hbox);
49
50 efl.ui.IButton about = new efl.ui.Button(hbox);
51 about.SetText("About");
52 about.FocusChangedEvt += FocusChangedCb;
53 about.ClickedEvt += AboutCb;
54 hbox.DoPack(about);
55
56 efl.ui.IButton quit = new efl.ui.Button(hbox);
57 quit.SetText("Quit");
58 quit.FocusChangedEvt += FocusChangedCb;
59 quit.ClickedEvt += QuitCb;
60 hbox.DoPack(quit);
61
62 efl.ui.focus.Util.Focus(about);
63
64 efl.ui.Config.Run();
65
66 efl.All.Shutdown();
67 }
68}
69
diff --git a/reference/csharp/ui/src/meson.build b/reference/csharp/ui/src/meson.build
index a975e0f..12a5ef3 100644
--- a/reference/csharp/ui/src/meson.build
+++ b/reference/csharp/ui/src/meson.build
@@ -13,3 +13,10 @@ executable('efl_reference_ui_container',
13 cs_args : efl_mono_libs, 13 cs_args : efl_mono_libs,
14 install : true 14 install : true
15) 15)
16
17executable('efl_reference_ui_focus',
18 files(['focus_main.cs']),
19 dependencies : deps,
20 cs_args : efl_mono_libs,
21 install : true
22)