2 using System.Collections.Generic;
3 using Tizen.NUI.BaseComponents;
4 using Tizen.NUI.Components;
6 namespace Tizen.NUI.Samples
8 public class InputFieldSample : IExample
10 private TextLabel guideText;
11 private View rootView;
12 InputField inputField;
13 InputFieldStyle inputFieldAttrs;
15 public void Activate()
17 Window window = Window.Instance;
21 WidthResizePolicy = ResizePolicyType.FillToParent,
22 HeightResizePolicy = ResizePolicyType.FillToParent,
23 BackgroundColor = new Color(0.8f, 0.8f, 0.8f, 0.8f),
27 rootView.TouchEvent += OnRootViewTouchEvent;
32 private void CreateGuideText()
34 guideText = new TextLabel();
35 guideText.Size2D = new Size2D(1600, 150);
36 guideText.Position2D = new Position2D(30, 30);
37 guideText.TextColor = Color.Blue;
38 guideText.BackgroundColor = Color.White;
39 guideText.PointSize = 15;
40 guideText.MultiLine = true;
41 guideText.Focusable = true;
42 rootView.Add(guideText);
45 "This InputField is created with attibutes; \n" +
46 "User can input text after press on it; \n" +
47 "User can exit the sample by press \"Esc\" key after touch on any area except the InputField.";
50 private void CreateInputField()
52 inputFieldAttrs = new InputFieldStyle();
53 inputFieldAttrs.Space = 24;
54 inputFieldAttrs.BackgroundImageAttributes = new ImageViewStyle
56 ResourceUrl = new Selector<string> { All = CommonResource.GetFHResourcePath() + "1. Action bar/search_bg.png" },
57 Border = new Selector<Rectangle> { All = new Rectangle(45, 45, 0, 0) }
60 inputFieldAttrs.InputBoxAttributes = new TextFieldStyle
62 TextColor = new Selector<Color>
64 Normal = new Color(0, 0, 0, 1),
65 Pressed = new Color(0, 0, 0, 1),
66 Disabled = new Color(0, 0, 0, 0.4f)
68 PlaceholderTextColor = new Selector<Color>
70 All = new Color(0, 0, 0, 0.4f)
72 HorizontalAlignment = HorizontalAlignment.Begin,
73 VerticalAlignment = VerticalAlignment.Center,
74 FontFamily = "SamsungOne 500",
75 PointSize = new Selector<float?>
82 inputField = new InputField(inputFieldAttrs);
83 inputField.Size2D = new Size2D(1600, 95);
84 inputField.Position2D = new Position2D(100, 300);
85 //inputField.Focusable = true;
86 rootView.Add(inputField);
87 inputField.FocusGained += onFocusGained;
88 inputField.FocusLost += onFocusLost;
89 //inputField.TouchEvent += onTouchEvent;
90 inputField.HintText = "Please input key word...";
93 private bool OnRootViewTouchEvent(object sender, View.TouchEventArgs e)
95 FocusManager.Instance.SetCurrentFocusView(rootView);
99 private void onFocusLost(object sender, EventArgs e)
104 private void onFocusGained(object sender, EventArgs e)
109 //private bool onTouchEvent(object sender, View.TouchEventArgs e)
114 public void Deactivate()
116 if (inputField != null)
118 inputField.FocusGained -= onFocusGained;
119 inputField.FocusLost -= onFocusLost;
120 //inputField.TouchEvent -= onTouchEvent;
121 rootView.Remove(inputField);
122 inputField.Dispose();
125 if (rootView != null)
127 rootView.TouchEvent -= OnRootViewTouchEvent;
128 Window.Instance.Remove(rootView);