2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.Runtime.InteropServices;
21 using Tizen.NUI.UIComponents;
22 using Tizen.NUI.BaseComponents;
23 using Tizen.NUI.Constants;
27 class Example : NUIApplication
29 TextLabel _pointLabel;
32 public Example() : base()
36 public Example(string stylesheet) : base(stylesheet)
40 public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode)
44 protected override void OnCreate()
50 private bool LabelTouched(object sender, View.TouchEventArgs e)
52 if (e.Touch.GetState(0) == PointStateType.Down)
54 Animation textColorAnimation = new Animation(1000);
57 textColorAnimation.AnimateTo(_pointLabel, "TextColorAnimatable", Color.Blue );
62 textColorAnimation.AnimateTo(_pointLabel, "TextColorAnimatable", Color.Green );
65 textColorAnimation.Play();
71 public void Initialize()
73 Window window = Window.Instance;
74 window.BackgroundColor = Color.White;
76 TextLabel pixelLabel = new TextLabel("Test Pixel Size 32.0f");
77 pixelLabel.Position2D = new Position2D(10, 10);
78 pixelLabel.PixelSize = 32.0f;
79 pixelLabel.BackgroundColor = Color.Magenta;
80 window.Add(pixelLabel);
82 _pointLabel = new TextLabel("Test Point Size 32.0f");
83 _pointLabel.Position2D = new Position2D(10, 100);
84 _pointLabel.PointSize = 32.0f;
85 _pointLabel.BackgroundColor = Color.Red;
86 //_pointLabel.TextColorAnimatable = Color.Green; // Set initial text color using animatable property
87 _pointLabel.TouchEvent += LabelTouched;
90 window.Add(_pointLabel);
93 TextLabel ellipsis = new TextLabel("Ellipsis of TextLabel is enabled.");
94 ellipsis.Size2D = new Size2D(100, 80);
95 ellipsis.Position2D = new Position2D(10, 200);
96 ellipsis.PointSize = 20.0f;
97 ellipsis.Ellipsis = true;
98 ellipsis.BackgroundColor = Color.Cyan;
101 TextLabel autoScrollStopMode = new TextLabel("AutoScrollStopMode is finish-loop.");
102 autoScrollStopMode.Size2D = new Size2D(400, 50);
103 autoScrollStopMode.Position2D = new Position2D(10, 300);
104 autoScrollStopMode.PointSize = 15.0f;
105 autoScrollStopMode.BackgroundColor = Color.Green;
106 autoScrollStopMode.AutoScrollStopMode = AutoScrollStopMode.FinishLoop;
107 autoScrollStopMode.EnableAutoScroll = true;
108 window.Add(autoScrollStopMode);
110 TextField field = new TextField();
111 field.Size2D = new Size2D(400, 100);
112 field.Position2D = new Position2D(10, 400);
113 field.BackgroundColor = Color.Cyan;
114 field.PlaceholderText = "input someth...";
115 field.PlaceholderTextFocused = "input someth... focused";
116 field.Focusable = true;
117 PropertyMap hiddenMap = new PropertyMap();
118 hiddenMap.Add(HiddenInputProperty.Mode, new PropertyValue((int)HiddenInputModeType.ShowLastCharacter));
119 hiddenMap.Add(HiddenInputProperty.ShowLastCharacterDuration, new PropertyValue(2));
120 hiddenMap.Add(HiddenInputProperty.SubstituteCount, new PropertyValue(4));
121 hiddenMap.Add(HiddenInputProperty.SubstituteCharacter, new PropertyValue(0x23));
122 field.HiddenInputSettings = hiddenMap;
123 field.EnableSelection = true;
124 field.EnableShiftSelection = false;
127 InputMethod inputMethod = new InputMethod();
128 inputMethod.PanelLayout = InputMethod.PanelLayoutType.Number;
129 inputMethod.ActionButton = InputMethod.ActionButtonTitleType.Go;
130 inputMethod.AutoCapital = InputMethod.AutoCapitalType.Word;
131 inputMethod.Variation = 1;
133 field.InputMethodSettings = inputMethod.OutputMap;
135 PropertyMap propertyMap = new PropertyMap();
136 propertyMap.Add("placeholderText", new PropertyValue("Placeholder Text"));
137 propertyMap.Add("placeholderTextFocused", new PropertyValue("Placeholder Text Focused"));
138 propertyMap.Add("placeholderColor", new PropertyValue(Color.Red));
139 propertyMap.Add("placeholderPointSize", new PropertyValue(15.0f));
141 PropertyMap fontStyleMap = new PropertyMap();
142 fontStyleMap.Add("weight", new PropertyValue("bold"));
143 fontStyleMap.Add("width", new PropertyValue("condensed"));
144 fontStyleMap.Add("slant", new PropertyValue("italic"));
145 propertyMap.Add("placeholderFontStyle", new PropertyValue(fontStyleMap));
147 TextEditor editor = new TextEditor();
148 editor.Size2D = new Size2D(400, 100);
149 editor.Position2D = new Position2D(10, 550);
150 editor.BackgroundColor = Color.Magenta;
151 editor.EnableScrollBar = true;
152 editor.EnableSelection = true;
153 editor.Focusable = true;
154 editor.Placeholder = propertyMap;
155 editor.MaxLength = 10;
157 editor.TextChanged += (obj, e) => {
158 Tizen.Log.Debug("NUI", "editor line count: " + e.TextEditor.LineCount);
161 editor.ScrollStateChanged += (obj, e)=> {
162 Tizen.Log.Debug("NUI", "editor scroll state:" + e.ScrollState);
164 editor.MaxLengthReached += (obj, e)=> {
165 Tizen.Log.Debug("NUI", "editor max length: "+ e.TextEditor.MaxLength);
168 Tizen.Log.Debug("NUI", "editor id: " + editor.ID);
170 FocusManager.Instance.SetCurrentFocusView(editor);
171 editor.UpFocusableView = field;
172 field.DownFocusableView = editor;
174 NUILog.Debug($"### field.EnableShiftSelection={field.EnableShiftSelection}, editor.EnableShiftSelection={editor.EnableShiftSelection}");
179 static void _Main(string[] args)
181 Example example = new Example();