2 * Copyright(c) 2019 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.
17 extern alias TizenSystemSettings;
18 using TizenSystemSettings.Tizen.System;
21 using System.Globalization;
22 using System.ComponentModel;
23 using Tizen.NUI.Binding;
25 namespace Tizen.NUI.BaseComponents
28 /// A control which provides a single line editable text field.
30 /// <since_tizen> 3 </since_tizen>
31 public partial class TextField : View
33 private string textFieldTextSid = null;
34 private string textFieldPlaceHolderTextSid = null;
35 private string textFieldPlaceHolderTextFocusedSid = null;
36 private bool systemlangTextFlag = false;
37 private InputMethodContext inputMethodCotext = null;
38 private TextFieldSelectorData selectorData;
39 private float fontSizeScale = 1.0f;
40 private bool hasFontSizeChangedCallback = false;
42 static TextField() { }
45 /// Creates the TextField control.
47 /// <since_tizen> 3 </since_tizen>
48 public TextField() : this(Interop.TextField.New(), true)
50 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
54 /// Creates the TextField with setting the status of shown or hidden.
56 /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
57 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
58 [EditorBrowsable(EditorBrowsableState.Never)]
59 public TextField(bool shown) : this(Interop.TextField.New(), true)
61 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
66 /// Get attributes, it is abstract function and must be override.
68 [EditorBrowsable(EditorBrowsableState.Never)]
69 protected override ViewStyle CreateViewStyle()
71 return new TextFieldStyle();
74 internal TextField(global::System.IntPtr cPtr, bool cMemoryOwn, ViewStyle viewStyle, bool shown = true) : base(cPtr, cMemoryOwn, viewStyle)
82 internal TextField(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(cPtr, cMemoryOwn, null)
90 internal TextField(TextField handle, bool shown = true) : this(Interop.TextField.NewTextField(TextField.getCPtr(handle)), true)
92 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
100 internal enum ExceedPolicyType
102 ExceedPolicyOriginal,
107 /// The TranslatableText property.<br />
108 /// The text can set the SID value.<br />
110 /// <exception cref='ArgumentNullException'>
111 /// ResourceManager about multilingual is null.
113 /// <since_tizen> 4 </since_tizen>
114 public string TranslatableText
118 return (string)GetValue(TranslatableTextProperty);
122 selectorData?.TranslatableText?.Reset(this);
123 SetValue(TranslatableTextProperty, value);
126 private string translatableText
130 return textFieldTextSid;
134 if (NUIApplication.MultilingualResourceManager == null)
136 throw new ArgumentNullException(null, "ResourceManager about multilingual is null");
138 textFieldTextSid = value;
139 Text = SetTranslatable(textFieldTextSid);
140 NotifyPropertyChanged();
145 /// The TranslatablePlaceholderText property.<br />
146 /// The text can set the SID value.<br />
148 /// <exception cref='ArgumentNullException'>
149 /// ResourceManager about multilingual is null.
151 /// <since_tizen> 4 </since_tizen>
152 public string TranslatablePlaceholderText
156 return (string)GetValue(TranslatablePlaceholderTextProperty);
160 SetValue(TranslatablePlaceholderTextProperty, value);
161 selectorData?.TranslatablePlaceholderText?.Reset(this);
164 private string translatablePlaceholderText
168 return textFieldPlaceHolderTextSid;
172 if (NUIApplication.MultilingualResourceManager == null)
174 throw new ArgumentNullException(null, "ResourceManager about multilingual is null");
176 textFieldPlaceHolderTextSid = value;
177 PlaceholderText = SetTranslatable(textFieldPlaceHolderTextSid);
178 NotifyPropertyChanged();
183 /// The TranslatablePlaceholderTextFocused property.<br />
184 /// The text can set the SID value.<br />
186 /// <exception cref='ArgumentNullException'>
187 /// ResourceManager about multilingual is null.
189 /// This will be public opened in tizen_6.5 after ACR done. Before ACR, need to be hidden as inhouse API.
190 [EditorBrowsable(EditorBrowsableState.Never)]
191 public string TranslatablePlaceholderTextFocused
195 return (string)GetValue(TranslatablePlaceholderTextFocusedProperty);
199 SetValue(TranslatablePlaceholderTextFocusedProperty, value);
200 selectorData?.TranslatablePlaceholderTextFocused?.Reset(this);
203 private string translatablePlaceholderTextFocused
207 return textFieldPlaceHolderTextFocusedSid;
211 if (NUIApplication.MultilingualResourceManager == null)
213 throw new ArgumentNullException(null, "ResourceManager about multilingual is null");
215 textFieldPlaceHolderTextFocusedSid = value;
216 PlaceholderTextFocused = SetTranslatable(textFieldPlaceHolderTextFocusedSid);
217 NotifyPropertyChanged();
222 /// The Text property.
224 /// <since_tizen> 3 </since_tizen>
229 return (string)GetValue(TextProperty);
233 SetValueAndForceSendChangeSignal(TextProperty, value);
234 selectorData?.Text?.Reset(this);
235 NotifyPropertyChanged();
240 /// The PlaceholderText property.
242 /// <since_tizen> 3 </since_tizen>
243 public string PlaceholderText
247 return (string)GetValue(PlaceholderTextProperty);
251 SetValue(PlaceholderTextProperty, value);
252 NotifyPropertyChanged();
257 /// The PlaceholderTextFocused property.
259 /// <since_tizen> 3 </since_tizen>
260 public string PlaceholderTextFocused
264 return (string)GetValue(PlaceholderTextFocusedProperty);
268 SetValue(PlaceholderTextFocusedProperty, value);
269 NotifyPropertyChanged();
274 /// The FontFamily property.
276 /// <since_tizen> 3 </since_tizen>
277 public string FontFamily
281 return (string)GetValue(FontFamilyProperty);
285 SetValue(FontFamilyProperty, value);
286 selectorData?.FontFamily?.Reset(this);
287 NotifyPropertyChanged();
292 /// The FontStyle property.
294 /// <since_tizen> 3 </since_tizen>
295 public PropertyMap FontStyle
299 return (PropertyMap)GetValue(FontStyleProperty);
303 SetValue(FontStyleProperty, value);
304 NotifyPropertyChanged();
309 /// The PointSize property.
311 /// <since_tizen> 3 </since_tizen>
312 public float PointSize
316 return (float)GetValue(PointSizeProperty);
320 SetValue(PointSizeProperty, value);
321 selectorData?.PointSize?.Reset(this);
322 NotifyPropertyChanged();
327 /// The MaxLength property.
329 /// <since_tizen> 3 </since_tizen>
334 return (int)GetValue(MaxLengthProperty);
338 SetValue(MaxLengthProperty, value);
339 NotifyPropertyChanged();
344 /// The ExceedPolicy property.
346 /// <since_tizen> 3 </since_tizen>
347 public int ExceedPolicy
351 return (int)GetValue(ExceedPolicyProperty);
355 SetValue(ExceedPolicyProperty, value);
356 NotifyPropertyChanged();
361 /// The HorizontalAlignment property.
363 /// <since_tizen> 3 </since_tizen>
364 public HorizontalAlignment HorizontalAlignment
368 return (HorizontalAlignment)GetValue(HorizontalAlignmentProperty);
372 SetValue(HorizontalAlignmentProperty, value);
373 NotifyPropertyChanged();
378 /// The VerticalAlignment property.
380 /// <since_tizen> 3 </since_tizen>
381 public VerticalAlignment VerticalAlignment
385 return (VerticalAlignment)GetValue(VerticalAlignmentProperty);
389 SetValue(VerticalAlignmentProperty, value);
390 NotifyPropertyChanged();
391 NotifyPropertyChanged();
396 /// The TextColor property.
399 /// The property cascade chaining set is possible. For example, this (textField.TextColor.X = 0.1f;) is possible.
401 /// <since_tizen> 3 </since_tizen>
402 public Color TextColor
406 Color temp = (Color)GetValue(TextColorProperty);
407 return new Color(OnTextColorChanged, temp.R, temp.G, temp.B, temp.A);
411 SetValue(TextColorProperty, value);
412 selectorData?.TextColor?.Reset(this);
413 NotifyPropertyChanged();
418 /// The PlaceholderTextColor property.
421 /// The property cascade chaining set is possible. For example, this (textField.PlaceholderTextColor.X = 0.1f;) is possible.
423 /// <since_tizen> 3 </since_tizen>
424 public Vector4 PlaceholderTextColor
428 Vector4 temp = (Vector4)GetValue(PlaceholderTextColorProperty);
429 return new Vector4(OnPlaceholderTextColorChanged, temp.X, temp.Y, temp.Z, temp.W);
433 SetValue(PlaceholderTextColorProperty, value);
434 selectorData?.PlaceholderTextColor?.Reset(this);
435 NotifyPropertyChanged();
440 /// The ShadowOffset property.
442 /// <since_tizen> 3 </since_tizen>
444 /// Deprecated.(API Level 6) Use Shadow instead.
445 /// The property cascade chaining set is possible. For example, this (textField.ShadowOffset.X = 0.1f;) is possible.
447 [Obsolete("Please do not use this ShadowOffset(Deprecated). Please use Shadow instead.")]
448 public Vector2 ShadowOffset
452 PropertyMap map = new PropertyMap();
453 GetProperty(TextField.Property.SHADOW).Get(map);
454 Vector2 shadowOffset = new Vector2();
455 map.Find(TextField.Property.SHADOW, "offset")?.Get(shadowOffset);
456 return new Vector2(OnShadowOffsetChanged, shadowOffset.X, shadowOffset.Y);
460 PropertyMap temp = new PropertyMap();
461 temp.Insert("offset", new PropertyValue(value));
462 SetValue(ShadowProperty, temp);
463 NotifyPropertyChanged();
468 /// The ShadowColor property.
470 /// <since_tizen> 3 </since_tizen>
472 /// Deprecated.(API Level 6) Use Shadow instead.
473 /// The property cascade chaining set is possible. For example, this (textField.ShadowColor.X = 0.1f;) is possible.
475 [Obsolete("Please do not use this ShadowColor(Deprecated). Please use Shadow instead.")]
476 public Vector4 ShadowColor
480 PropertyMap map = new PropertyMap();
481 GetProperty(TextField.Property.SHADOW).Get(map);
482 Vector4 shadowColor = new Vector4();
483 map.Find(TextField.Property.SHADOW, "color")?.Get(shadowColor);
484 return new Vector4(OnShadowColorChanged, shadowColor.X, shadowColor.Y, shadowColor.Z, shadowColor.W);
488 PropertyMap temp = new PropertyMap();
489 temp.Insert("color", new PropertyValue(value));
490 SetValue(ShadowProperty, temp);
491 NotifyPropertyChanged();
496 /// The PrimaryCursorColor property.
499 /// The property cascade chaining set is possible. For example, this (textField.PrimaryCursorColor.X = 0.1f;) is possible.
501 /// <since_tizen> 3 </since_tizen>
502 public Vector4 PrimaryCursorColor
506 Vector4 temp = (Vector4)GetValue(PrimaryCursorColorProperty);
507 return new Vector4(OnPrimaryCursorColorChanged, temp.X, temp.Y, temp.Z, temp.W);
511 SetValue(PrimaryCursorColorProperty, value);
512 selectorData?.PrimaryCursorColor?.Reset(this);
513 NotifyPropertyChanged();
518 /// The SecondaryCursorColor property.
521 /// The property cascade chaining set is possible. For example, this (textField.SecondaryCursorColor.X = 0.1f;) is possible.
523 /// <since_tizen> 3 </since_tizen>
524 public Vector4 SecondaryCursorColor
528 Vector4 temp = (Vector4)GetValue(SecondaryCursorColorProperty);
529 return new Vector4(OnSecondaryCursorColorChanged, temp.X, temp.Y, temp.Z, temp.W);
533 SetValue(SecondaryCursorColorProperty, value);
534 NotifyPropertyChanged();
539 /// The EnableCursorBlink property.
541 /// <since_tizen> 3 </since_tizen>
542 public bool EnableCursorBlink
546 return (bool)GetValue(EnableCursorBlinkProperty);
550 SetValue(EnableCursorBlinkProperty, value);
551 NotifyPropertyChanged();
556 /// The CursorBlinkInterval property.
558 /// <since_tizen> 3 </since_tizen>
559 public float CursorBlinkInterval
563 return (float)GetValue(CursorBlinkIntervalProperty);
567 SetValue(CursorBlinkIntervalProperty, value);
568 NotifyPropertyChanged();
573 /// The CursorBlinkDuration property.
575 /// <since_tizen> 3 </since_tizen>
576 public float CursorBlinkDuration
580 return (float)GetValue(CursorBlinkDurationProperty);
584 SetValue(CursorBlinkDurationProperty, value);
585 NotifyPropertyChanged();
590 /// The CursorWidth property.
592 /// <since_tizen> 3 </since_tizen>
593 public int CursorWidth
597 return (int)GetValue(CursorWidthProperty);
601 SetValue(CursorWidthProperty, value);
602 NotifyPropertyChanged();
607 /// The GrabHandleImage property.
609 /// <since_tizen> 3 </since_tizen>
610 public string GrabHandleImage
614 return (string)GetValue(GrabHandleImageProperty);
618 SetValue(GrabHandleImageProperty, value);
619 NotifyPropertyChanged();
624 /// The GrabHandlePressedImage property.
626 /// <since_tizen> 3 </since_tizen>
627 public string GrabHandlePressedImage
631 return (string)GetValue(GrabHandlePressedImageProperty);
635 SetValue(GrabHandlePressedImageProperty, value);
636 NotifyPropertyChanged();
641 /// The ScrollThreshold property.
643 /// <since_tizen> 3 </since_tizen>
644 public float ScrollThreshold
648 return (float)GetValue(ScrollThresholdProperty);
652 SetValue(ScrollThresholdProperty, value);
653 NotifyPropertyChanged();
658 /// The ScrollSpeed property.
660 /// <since_tizen> 3 </since_tizen>
661 public float ScrollSpeed
665 return (float)GetValue(ScrollSpeedProperty);
669 SetValue(ScrollSpeedProperty, value);
670 NotifyPropertyChanged();
675 /// The SelectionHandleImageLeft property.
677 /// <since_tizen> 3 </since_tizen>
678 public PropertyMap SelectionHandleImageLeft
682 return (PropertyMap)GetValue(SelectionHandleImageLeftProperty);
686 SetValue(SelectionHandleImageLeftProperty, value);
687 NotifyPropertyChanged();
692 /// The SelectionHandleImageRight property.
694 /// <since_tizen> 3 </since_tizen>
695 public PropertyMap SelectionHandleImageRight
699 return (PropertyMap)GetValue(SelectionHandleImageRightProperty);
703 SetValue(SelectionHandleImageRightProperty, value);
704 NotifyPropertyChanged();
709 /// The SelectionHandlePressedImageLeft property.
711 /// <since_tizen> 3 </since_tizen>
712 public PropertyMap SelectionHandlePressedImageLeft
716 return (PropertyMap)GetValue(SelectionHandlePressedImageLeftProperty);
720 SetValue(SelectionHandlePressedImageLeftProperty, value);
721 NotifyPropertyChanged();
726 /// The SelectionHandlePressedImageRight property.
728 /// <since_tizen> 3 </since_tizen>
729 public PropertyMap SelectionHandlePressedImageRight
733 return (PropertyMap)GetValue(SelectionHandlePressedImageRightProperty);
737 SetValue(SelectionHandlePressedImageRightProperty, value);
738 NotifyPropertyChanged();
743 /// The SelectionHandleMarkerImageLeft property.
745 /// <since_tizen> 3 </since_tizen>
746 public PropertyMap SelectionHandleMarkerImageLeft
750 return (PropertyMap)GetValue(SelectionHandleMarkerImageLeftProperty);
754 SetValue(SelectionHandleMarkerImageLeftProperty, value);
755 NotifyPropertyChanged();
760 /// The SelectionHandleMarkerImageRight property.
762 /// <since_tizen> 3 </since_tizen>
763 public PropertyMap SelectionHandleMarkerImageRight
767 return (PropertyMap)GetValue(SelectionHandleMarkerImageRightProperty);
771 SetValue(SelectionHandleMarkerImageRightProperty, value);
772 NotifyPropertyChanged();
777 /// The SelectionHighlightColor property.
780 /// The property cascade chaining set is possible. For example, this (textField.SelectionHighlightColor.X = 0.1f;) is possible.
782 /// <since_tizen> 3 </since_tizen>
783 public Vector4 SelectionHighlightColor
787 Vector4 temp = (Vector4)GetValue(SelectionHighlightColorProperty);
788 return new Vector4(OnSelectionHighlightColorChanged, temp.X, temp.Y, temp.Z, temp.W);
792 SetValue(SelectionHighlightColorProperty, value);
793 NotifyPropertyChanged();
798 /// The DecorationBoundingBox property.
801 /// The property cascade chaining set is possible. For example, this (textField.DecorationBoundingBox.X = 0.1f;) is possible.
803 /// <since_tizen> 3 </since_tizen>
804 public Rectangle DecorationBoundingBox
808 Rectangle temp = (Rectangle)GetValue(DecorationBoundingBoxProperty);
809 return new Rectangle(OnDecorationBoundingBoxChanged, temp.X, temp.Y, temp.Width, temp.Height);
813 SetValue(DecorationBoundingBoxProperty, value);
814 NotifyPropertyChanged();
819 /// The InputMethodSettings property.
821 /// <since_tizen> 3 </since_tizen>
822 public PropertyMap InputMethodSettings
826 return (PropertyMap)GetValue(InputMethodSettingsProperty);
830 SetValue(InputMethodSettingsProperty, value);
831 NotifyPropertyChanged();
836 /// The InputColor property.
839 /// The property cascade chaining set is possible. For example, this (textField.InputColor.X = 0.1f;) is possible.
841 /// <since_tizen> 3 </since_tizen>
842 public Vector4 InputColor
846 Vector4 temp = (Vector4)GetValue(InputColorProperty);
847 return new Vector4(OnInputColorChanged, temp.X, temp.Y, temp.Z, temp.W);
851 SetValue(InputColorProperty, value);
852 NotifyPropertyChanged();
857 /// The EnableMarkup property.
859 /// <since_tizen> 3 </since_tizen>
860 public bool EnableMarkup
864 return (bool)GetValue(EnableMarkupProperty);
868 SetValue(EnableMarkupProperty, value);
869 NotifyPropertyChanged();
874 /// The InputFontFamily property.
876 /// <since_tizen> 3 </since_tizen>
877 public string InputFontFamily
881 return (string)GetValue(InputFontFamilyProperty);
885 SetValue(InputFontFamilyProperty, value);
886 NotifyPropertyChanged();
891 /// The InputFontStyle property.
893 /// <since_tizen> 3 </since_tizen>
894 public PropertyMap InputFontStyle
898 return (PropertyMap)GetValue(InputFontStyleProperty);
902 SetValue(InputFontStyleProperty, value);
903 NotifyPropertyChanged();
908 /// The InputPointSize property.
910 /// <since_tizen> 3 </since_tizen>
911 public float InputPointSize
915 return (float)GetValue(InputPointSizeProperty);
919 SetValue(InputPointSizeProperty, value);
920 NotifyPropertyChanged();
925 /// The Underline property.
927 /// <since_tizen> 3 </since_tizen>
928 public PropertyMap Underline
932 return (PropertyMap)GetValue(UnderlineProperty);
936 SetValue(UnderlineProperty, value);
937 NotifyPropertyChanged();
942 /// The InputUnderline property.
944 /// <since_tizen> 3 </since_tizen>
945 public string InputUnderline
949 return (string)GetValue(InputUnderlineProperty);
953 SetValue(InputUnderlineProperty, value);
954 NotifyPropertyChanged();
959 /// The Shadow property.
961 /// <since_tizen> 3 </since_tizen>
962 public PropertyMap Shadow
966 return (PropertyMap)GetValue(ShadowProperty);
970 SetValue(ShadowProperty, value);
971 NotifyPropertyChanged();
976 /// The InputShadow property.
978 /// <since_tizen> 3 </since_tizen>
979 public string InputShadow
983 return (string)GetValue(InputShadowProperty);
987 SetValue(InputShadowProperty, value);
988 NotifyPropertyChanged();
993 /// The Emboss property.
995 /// <since_tizen> 3 </since_tizen>
1000 return (string)GetValue(EmbossProperty);
1004 SetValue(EmbossProperty, value);
1005 NotifyPropertyChanged();
1010 /// The InputEmboss property.
1012 /// <since_tizen> 3 </since_tizen>
1013 public string InputEmboss
1017 return (string)GetValue(InputEmbossProperty);
1021 SetValue(InputEmbossProperty, value);
1022 NotifyPropertyChanged();
1027 /// The Outline property.
1029 /// <since_tizen> 3 </since_tizen>
1030 public PropertyMap Outline
1034 return (PropertyMap)GetValue(OutlineProperty);
1038 SetValue(OutlineProperty, value);
1039 NotifyPropertyChanged();
1044 /// The InputOutline property.
1046 /// <since_tizen> 3 </since_tizen>
1047 public string InputOutline
1051 return (string)GetValue(InputOutlineProperty);
1055 SetValue(InputOutlineProperty, value);
1056 NotifyPropertyChanged();
1061 /// The HiddenInputSettings property.
1063 /// <since_tizen> 3 </since_tizen>
1064 public Tizen.NUI.PropertyMap HiddenInputSettings
1068 return (PropertyMap)GetValue(HiddenInputSettingsProperty);
1072 SetValue(HiddenInputSettingsProperty, value);
1073 NotifyPropertyChanged();
1078 /// The PixelSize property.
1080 /// <since_tizen> 3 </since_tizen>
1081 public float PixelSize
1085 return (float)GetValue(PixelSizeProperty);
1089 SetValue(PixelSizeProperty, value);
1090 selectorData?.PixelSize?.Reset(this);
1091 NotifyPropertyChanged();
1096 /// The Enable selection property.
1098 /// <since_tizen> 3 </since_tizen>
1099 public bool EnableSelection
1103 return (bool)GetValue(EnableSelectionProperty);
1107 SetValue(EnableSelectionProperty, value);
1108 NotifyPropertyChanged();
1113 /// The Enable selection property.
1115 /// <since_tizen> 6 </since_tizen>
1116 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
1117 [EditorBrowsable(EditorBrowsableState.Never)]
1118 public bool EnableGrabHandle
1122 return (bool)GetValue(EnableGrabHandleProperty);
1126 SetValue(EnableGrabHandleProperty, value);
1127 NotifyPropertyChanged();
1132 /// The Enable selection property.
1134 /// <since_tizen> 6 </since_tizen>
1135 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
1136 [EditorBrowsable(EditorBrowsableState.Never)]
1137 public bool EnableGrabHandlePopup
1141 return (bool)GetValue(EnableGrabHandlePopupProperty);
1145 SetValue(EnableGrabHandlePopupProperty, value);
1146 NotifyPropertyChanged();
1151 /// The Selected Text property.
1153 /// <since_tizen> 8 </since_tizen>
1154 /// This will be public opened in tizen_6.0 after ACR done, Before ACR, need to be hidden as inhouse API.
1155 [EditorBrowsable(EditorBrowsableState.Never)]
1156 public string SelectedText
1161 GetProperty(TextField.Property.SelectedText).Get(out temp);
1167 /// The start index for selection.
1169 /// <since_tizen> 8 </since_tizen>
1170 /// This will be public opened in tizen_6.0 after ACR done, Before ACR, need to be hidden as inhouse API.
1171 [EditorBrowsable(EditorBrowsableState.Never)]
1172 public int SelectedTextStart
1177 GetProperty(TextField.Property.SelectedTextStart).Get(out temp);
1182 SetProperty(TextField.Property.SelectedTextStart, new PropertyValue(value));
1183 NotifyPropertyChanged();
1188 /// The end index for selection.
1190 /// <since_tizen> 8 </since_tizen>
1191 /// This will be public opened in tizen_6.0 after ACR done, Before ACR, need to be hidden as inhouse API.
1192 [EditorBrowsable(EditorBrowsableState.Never)]
1193 public int SelectedTextEnd
1198 GetProperty(TextField.Property.SelectedTextEnd).Get(out temp);
1203 SetProperty(TextField.Property.SelectedTextEnd, new PropertyValue(value));
1204 NotifyPropertyChanged();
1209 /// Enable editing in text control.
1211 /// <since_tizen> 8 </since_tizen>
1212 /// This will be public opened in tizen_6.0 after ACR done, Before ACR, need to be hidden as inhouse API.
1213 [EditorBrowsable(EditorBrowsableState.Never)]
1214 public bool EnableEditing
1219 GetProperty(TextField.Property.EnableEditing).Get(out temp);
1224 SetProperty(TextField.Property.EnableEditing, new PropertyValue(value));
1225 NotifyPropertyChanged();
1230 /// Specify primary cursor (caret) position in text control.
1232 [EditorBrowsable(EditorBrowsableState.Never)]
1233 public int PrimaryCursorPosition
1238 using (PropertyValue propertyValue = GetProperty(TextField.Property.PrimaryCursorPosition))
1240 propertyValue.Get(out temp);
1246 using (PropertyValue propertyValue = new PropertyValue(value))
1248 SetProperty(TextField.Property.PrimaryCursorPosition, propertyValue);
1249 NotifyPropertyChanged();
1255 /// The Placeholder property.
1256 /// Gets or sets the placeholder: text, color, font family, font style, point size, and pixel size.
1259 /// The following example demonstrates how to set the Placeholder property.
1261 /// PropertyMap propertyMap = new PropertyMap();
1262 /// propertyMap.Add("text", new PropertyValue("Setting Placeholder Text"));
1263 /// propertyMap.Add("textFocused", new PropertyValue("Setting Placeholder Text Focused"));
1264 /// propertyMap.Add("color", new PropertyValue(Color.Red));
1265 /// propertyMap.Add("fontFamily", new PropertyValue("Arial"));
1266 /// propertyMap.Add("pointSize", new PropertyValue(12.0f));
1268 /// PropertyMap fontStyleMap = new PropertyMap();
1269 /// fontStyleMap.Add("weight", new PropertyValue("bold"));
1270 /// fontStyleMap.Add("width", new PropertyValue("condensed"));
1271 /// fontStyleMap.Add("slant", new PropertyValue("italic"));
1272 /// propertyMap.Add("fontStyle", new PropertyValue(fontStyleMap));
1274 /// TextField field = new TextField();
1275 /// field.Placeholder = propertyMap;
1278 /// <since_tizen> 3 </since_tizen>
1279 public Tizen.NUI.PropertyMap Placeholder
1283 return (PropertyMap)GetValue(PlaceholderProperty);
1287 SetValue(PlaceholderProperty, value);
1288 NotifyPropertyChanged();
1293 /// The Ellipsis property.<br />
1294 /// Enable or disable the ellipsis.<br />
1295 /// Placeholder PropertyMap is used to add ellipsis to placeholder text.
1297 /// <since_tizen> 4 </since_tizen>
1298 public bool Ellipsis
1302 return (bool)GetValue(EllipsisProperty);
1306 SetValue(EllipsisProperty, value);
1307 NotifyPropertyChanged();
1312 /// Enables selection of the text using the Shift key.
1314 /// <since_tizen> 5 </since_tizen>
1315 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
1316 [EditorBrowsable(EditorBrowsableState.Never)]
1317 public bool EnableShiftSelection
1321 return (bool)GetValue(EnableShiftSelectionProperty);
1325 SetValue(EnableShiftSelectionProperty, value);
1326 NotifyPropertyChanged();
1331 /// The text alignment to match the direction of the system language.
1333 /// <since_tizen> 6 </since_tizen>
1334 public bool MatchSystemLanguageDirection
1338 return (bool)GetValue(MatchSystemLanguageDirectionProperty);
1342 SetValue(MatchSystemLanguageDirectionProperty, value);
1343 NotifyPropertyChanged();
1348 /// The FontSizeScale property. <br />
1349 /// The default value is 1.0. <br />
1350 /// If FontSizeScale.UseSystemSetting, will use the SystemSettings.FontSize internally. <br />
1352 /// <since_tizen> 9 </since_tizen>
1353 public float FontSizeScale
1357 return fontSizeScale;
1361 float newFontSizeScale;
1363 if (fontSizeScale == value) return;
1365 fontSizeScale = value;
1366 if (fontSizeScale == Tizen.NUI.FontSizeScale.UseSystemSetting)
1368 SystemSettingsFontSize systemSettingsFontSize;
1372 systemSettingsFontSize = SystemSettings.FontSize;
1376 Console.WriteLine("{0} Exception caught.", e);
1377 systemSettingsFontSize = SystemSettingsFontSize.Normal;
1379 newFontSizeScale = TextUtils.GetFontSizeScale(systemSettingsFontSize);
1380 addFontSizeChangedCallback();
1384 newFontSizeScale = fontSizeScale;
1385 removeFontSizeChangedCallback();
1388 SetValue(FontSizeScaleProperty, newFontSizeScale);
1389 NotifyPropertyChanged();
1393 /// Only used by the IL of xaml, will never changed to not hidden.
1394 [EditorBrowsable(EditorBrowsableState.Never)]
1395 public override bool IsCreateByXaml
1399 return base.IsCreateByXaml;
1403 base.IsCreateByXaml = value;
1407 this.TextChanged += (obj, e) =>
1409 this.Text = e.TextField.Text;
1415 private TextFieldSelectorData EnsureSelectorData() => selectorData ?? (selectorData = new TextFieldSelectorData());
1418 /// Get the InputMethodContext instance.
1420 /// <returns>The InputMethodContext instance.</returns>
1421 /// <since_tizen> 5 </since_tizen>
1422 public InputMethodContext GetInputMethodContext()
1424 if (inputMethodCotext == null)
1426 /*Avoid raising InputMethodContext reference count.*/
1427 inputMethodCotext = new InputMethodContext(Interop.TextField.GetInputMethodContext(SwigCPtr), true);
1428 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1430 return inputMethodCotext;
1434 /// Select the whole text.
1436 /// <since_tizen> 6 </since_tizen>
1437 /// This will be released at Tizen.NET API Level 5.5, so currently this would be used as inhouse API.
1438 [EditorBrowsable(EditorBrowsableState.Never)]
1439 public void SelectWholeText()
1441 Interop.TextField.SelectWholeText(SwigCPtr);
1442 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1446 /// Clear selection of the text.
1448 /// <since_tizen> 8 </since_tizen>
1449 /// This will be public opened in tizen_6.0 after ACR done, Before ACR, need to be hidden as inhouse API.
1450 [EditorBrowsable(EditorBrowsableState.Never)]
1451 public void SelectNone()
1453 _ = Interop.TextField.SelectNone(SwigCPtr);
1454 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1457 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TextField obj)
1459 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
1462 internal SWIGTYPE_p_Dali__SignalT_void_fDali__Toolkit__TextField_Dali__Toolkit__TextField__InputStyle__MaskF_t InputStyleChangedSignal()
1464 SWIGTYPE_p_Dali__SignalT_void_fDali__Toolkit__TextField_Dali__Toolkit__TextField__InputStyle__MaskF_t ret = new SWIGTYPE_p_Dali__SignalT_void_fDali__Toolkit__TextField_Dali__Toolkit__TextField__InputStyle__MaskF_t(Interop.TextField.InputStyleChangedSignal(SwigCPtr));
1465 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1472 /// <since_tizen> 3 </since_tizen>
1473 protected override void Dispose(DisposeTypes type)
1477 DisposeQueue.Instance.Add(this);
1481 if (systemlangTextFlag)
1483 SystemSettings.LocaleLanguageChanged -= SystemSettings_LocaleLanguageChanged;
1486 removeFontSizeChangedCallback();
1488 if (type == DisposeTypes.Explicit)
1491 //Release your own managed resources here.
1492 //You should release all of your own disposable objects here.
1493 selectorData?.Reset(this);
1496 //Release your own unmanaged resources here.
1497 //You should not access any managed member here except static instance.
1498 //because the execution order of Finalizes is non-deterministic.
1501 if (textFieldMaxLengthReachedCallbackDelegate != null)
1503 this.MaxLengthReachedSignal().Disconnect(textFieldMaxLengthReachedCallbackDelegate);
1506 if (textFieldTextChangedCallbackDelegate != null)
1508 TextChangedSignal().Disconnect(textFieldTextChangedCallbackDelegate);
1515 /// This will not be public opened.
1516 [EditorBrowsable(EditorBrowsableState.Never)]
1517 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1519 // In order to speed up IME hide, temporarily add
1520 GetInputMethodContext()?.DestroyContext();
1521 Interop.TextField.DeleteTextField(swigCPtr);
1524 private string SetTranslatable(string textFieldSid)
1526 string translatableText = null;
1527 translatableText = NUIApplication.MultilingualResourceManager?.GetString(textFieldSid, new CultureInfo(SystemSettings.LocaleLanguage.Replace("_", "-")));
1528 if (translatableText != null)
1530 if (systemlangTextFlag == false)
1532 SystemSettings.LocaleLanguageChanged += SystemSettings_LocaleLanguageChanged;
1533 systemlangTextFlag = true;
1535 return translatableText;
1539 translatableText = "";
1540 return translatableText;
1544 private void SystemSettings_LocaleLanguageChanged(object sender, LocaleLanguageChangedEventArgs e)
1546 if (textFieldTextSid != null)
1548 Text = NUIApplication.MultilingualResourceManager?.GetString(textFieldTextSid, new CultureInfo(e.Value.Replace("_", "-")));
1550 if (textFieldPlaceHolderTextSid != null)
1552 PlaceholderText = NUIApplication.MultilingualResourceManager?.GetString(textFieldPlaceHolderTextSid, new CultureInfo(e.Value.Replace("_", "-")));
1554 if (textFieldPlaceHolderTextFocusedSid != null)
1556 PlaceholderTextFocused = NUIApplication.MultilingualResourceManager?.GetString(textFieldPlaceHolderTextFocusedSid, new CultureInfo(e.Value.Replace("_", "-")));
1560 private void SystemSettingsFontSizeChanged(object sender, FontSizeChangedEventArgs e)
1562 float newFontSizeScale = TextUtils.GetFontSizeScale(e.Value);
1563 SetValue(FontSizeScaleProperty, newFontSizeScale);
1564 NotifyPropertyChanged();
1567 private void addFontSizeChangedCallback()
1569 if (hasFontSizeChangedCallback != true)
1573 SystemSettings.FontSizeChanged += SystemSettingsFontSizeChanged;
1574 hasFontSizeChangedCallback = true;
1578 Console.WriteLine("{0} Exception caught.", e);
1579 hasFontSizeChangedCallback = false;
1584 private void removeFontSizeChangedCallback()
1586 if (hasFontSizeChangedCallback == true)
1590 SystemSettings.FontSizeChanged -= SystemSettingsFontSizeChanged;
1591 hasFontSizeChangedCallback = false;
1595 Console.WriteLine("{0} Exception caught.", e);
1596 hasFontSizeChangedCallback = true;
1601 internal new class Property
1603 internal static readonly int TEXT = Interop.TextField.TextGet();
1604 internal static readonly int PlaceholderText = Interop.TextField.PlaceholderTextGet();
1605 internal static readonly int PlaceholderTextFocused = Interop.TextField.PlaceholderTextFocusedGet();
1606 internal static readonly int FontFamily = Interop.TextField.FontFamilyGet();
1607 internal static readonly int FontStyle = Interop.TextField.FontStyleGet();
1608 internal static readonly int PointSize = Interop.TextField.PointSizeGet();
1609 internal static readonly int MaxLength = Interop.TextField.MaxLengthGet();
1610 internal static readonly int ExceedPolicy = Interop.TextField.ExceedPolicyGet();
1611 internal static readonly int HorizontalAlignment = Interop.TextField.HorizontalAlignmentGet();
1612 internal static readonly int VerticalAlignment = Interop.TextField.VerticalAlignmentGet();
1613 internal static readonly int TextColor = Interop.TextField.TextColorGet();
1614 internal static readonly int PlaceholderTextColor = Interop.TextField.PlaceholderTextColorGet();
1615 internal static readonly int PrimaryCursorColor = Interop.TextField.PrimaryCursorColorGet();
1616 internal static readonly int SecondaryCursorColor = Interop.TextField.SecondaryCursorColorGet();
1617 internal static readonly int EnableCursorBlink = Interop.TextField.EnableCursorBlinkGet();
1618 internal static readonly int CursorBlinkInterval = Interop.TextField.CursorBlinkIntervalGet();
1619 internal static readonly int CursorBlinkDuration = Interop.TextField.CursorBlinkDurationGet();
1620 internal static readonly int CursorWidth = Interop.TextField.CursorWidthGet();
1621 internal static readonly int GrabHandleImage = Interop.TextField.GrabHandleImageGet();
1622 internal static readonly int GrabHandlePressedImage = Interop.TextField.GrabHandlePressedImageGet();
1623 internal static readonly int ScrollThreshold = Interop.TextField.ScrollThresholdGet();
1624 internal static readonly int ScrollSpeed = Interop.TextField.ScrollSpeedGet();
1625 internal static readonly int SelectionHandleImageLeft = Interop.TextField.SelectionHandleImageLeftGet();
1626 internal static readonly int SelectionHandleImageRight = Interop.TextField.SelectionHandleImageRightGet();
1627 internal static readonly int SelectionHandlePressedImageLeft = Interop.TextField.SelectionHandlePressedImageLeftGet();
1628 internal static readonly int SelectionHandlePressedImageRight = Interop.TextField.SelectionHandlePressedImageRightGet();
1629 internal static readonly int SelectionHandleMarkerImageLeft = Interop.TextField.SelectionHandleMarkerImageLeftGet();
1630 internal static readonly int SelectionHandleMarkerImageRight = Interop.TextField.SelectionHandleMarkerImageRightGet();
1631 internal static readonly int SelectionHighlightColor = Interop.TextField.SelectionHighlightColorGet();
1632 internal static readonly int DecorationBoundingBox = Interop.TextField.DecorationBoundingBoxGet();
1633 internal static readonly int InputMethodSettings = Interop.TextField.InputMethodSettingsGet();
1634 internal static readonly int InputColor = Interop.TextField.InputColorGet();
1635 internal static readonly int EnableMarkup = Interop.TextField.EnableMarkupGet();
1636 internal static readonly int InputFontFamily = Interop.TextField.InputFontFamilyGet();
1637 internal static readonly int InputFontStyle = Interop.TextField.InputFontStyleGet();
1638 internal static readonly int InputPointSize = Interop.TextField.InputPointSizeGet();
1639 internal static readonly int UNDERLINE = Interop.TextField.UnderlineGet();
1640 internal static readonly int InputUnderline = Interop.TextField.InputUnderlineGet();
1641 internal static readonly int SHADOW = Interop.TextField.ShadowGet();
1642 internal static readonly int InputShadow = Interop.TextField.InputShadowGet();
1643 internal static readonly int EMBOSS = Interop.TextField.EmbossGet();
1644 internal static readonly int InputEmboss = Interop.TextField.InputEmbossGet();
1645 internal static readonly int OUTLINE = Interop.TextField.OutlineGet();
1646 internal static readonly int InputOutline = Interop.TextField.InputOutlineGet();
1647 internal static readonly int HiddenInputSettings = Interop.TextField.HiddenInputSettingsGet();
1648 internal static readonly int PixelSize = Interop.TextField.PixelSizeGet();
1649 internal static readonly int EnableSelection = Interop.TextField.EnableSelectionGet();
1650 internal static readonly int PLACEHOLDER = Interop.TextField.PlaceholderGet();
1651 internal static readonly int ELLIPSIS = Interop.TextField.EllipsisGet();
1652 internal static readonly int EnableShiftSelection = Interop.TextField.EnableShiftSelectionGet();
1653 internal static readonly int MatchSystemLanguageDirection = Interop.TextField.MatchSystemLanguageDirectionGet();
1654 internal static readonly int EnableGrabHandle = Interop.TextField.EnableGrabHandleGet();
1655 internal static readonly int EnableGrabHandlePopup = Interop.TextField.EnableGrabHandlePopupGet();
1656 internal static readonly int SelectedText = Interop.TextField.SelectedTextGet();
1657 internal static readonly int SelectedTextStart = Interop.TextField.SelectedTextStartGet();
1658 internal static readonly int SelectedTextEnd = Interop.TextField.SelectedTextEndGet();
1659 internal static readonly int EnableEditing = Interop.TextField.EnableEditingGet();
1660 internal static readonly int PrimaryCursorPosition = Interop.TextField.PrimaryCursorPositionGet();
1661 internal static readonly int FontSizeScale = Interop.TextField.FontSizeScaleGet();
1664 internal class InputStyle
1670 FontFamily = 0x0002,
1680 private void OnDecorationBoundingBoxChanged(int x, int y, int width, int height)
1682 DecorationBoundingBox = new Rectangle(x, y, width, height);
1684 private void OnInputColorChanged(float x, float y, float z, float w)
1686 InputColor = new Vector4(x, y, z, w);
1688 private void OnPlaceholderTextColorChanged(float r, float g, float b, float a)
1690 PlaceholderTextColor = new Vector4(r, g, b, a);
1692 private void OnPrimaryCursorColorChanged(float x, float y, float z, float w)
1694 PrimaryCursorColor = new Vector4(x, y, z, w);
1696 private void OnSecondaryCursorColorChanged(float x, float y, float z, float w)
1698 SecondaryCursorColor = new Vector4(x, y, z, w);
1700 private void OnSelectionHighlightColorChanged(float x, float y, float z, float w)
1702 SelectionHighlightColor = new Vector4(x, y, z, w);
1704 private void OnShadowColorChanged(float x, float y, float z, float w)
1706 ShadowColor = new Vector4(x, y, z, w);
1708 private void OnShadowOffsetChanged(float x, float y)
1710 ShadowOffset = new Vector2(x, y);
1712 private void OnTextColorChanged(float r, float g, float b, float a)
1714 TextColor = new Color(r, g, b, a);