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 bool systemlangTextFlag = false;
36 private InputMethodContext inputMethodCotext = null;
37 private TextFieldSelectorData selectorData;
38 private float fontSizeScale = 1.0f;
39 private bool hasFontSizeChangedCallback = false;
41 static TextField() { }
44 /// Creates the TextField control.
46 /// <since_tizen> 3 </since_tizen>
47 public TextField() : this(Interop.TextField.New(), true)
49 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
53 /// Creates the TextField with setting the status of shown or hidden.
55 /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
56 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
57 [EditorBrowsable(EditorBrowsableState.Never)]
58 public TextField(bool shown) : this(Interop.TextField.New(), true)
60 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
65 /// Get attribues, it is abstract function and must be override.
67 [EditorBrowsable(EditorBrowsableState.Never)]
68 protected override ViewStyle CreateViewStyle()
70 return new TextFieldStyle();
73 internal TextField(global::System.IntPtr cPtr, bool cMemoryOwn, ViewStyle viewStyle, bool shown = true) : base(cPtr, cMemoryOwn, viewStyle)
81 internal TextField(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(cPtr, cMemoryOwn, null)
89 internal TextField(TextField handle, bool shown = true) : this(Interop.TextField.NewTextField(TextField.getCPtr(handle)), true)
91 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
99 internal enum ExceedPolicyType
101 ExceedPolicyOriginal,
106 /// The TranslatableText property.<br />
107 /// The text can set the SID value.<br />
109 /// <exception cref='ArgumentNullException'>
110 /// ResourceManager about multilingual is null.
112 /// <since_tizen> 4 </since_tizen>
113 public string TranslatableText
117 return (string)GetValue(TranslatableTextProperty);
121 selectorData?.TranslatableText?.Reset(this);
122 SetValue(TranslatableTextProperty, value);
125 private string translatableText
129 return textFieldTextSid;
133 if (NUIApplication.MultilingualResourceManager == null)
135 throw new ArgumentNullException(null, "ResourceManager about multilingual is null");
137 textFieldTextSid = value;
138 Text = SetTranslatable(textFieldTextSid);
139 NotifyPropertyChanged();
144 /// The TranslatablePlaceholderText property.<br />
145 /// The text can set the SID value.<br />
147 /// <exception cref='ArgumentNullException'>
148 /// ResourceManager about multilingual is null.
150 /// <since_tizen> 4 </since_tizen>
151 public string TranslatablePlaceholderText
155 return (string)GetValue(TranslatablePlaceholderTextProperty);
159 SetValue(TranslatablePlaceholderTextProperty, value);
160 selectorData?.TranslatablePlaceholderText?.Reset(this);
163 private string translatablePlaceholderText
167 return textFieldPlaceHolderTextSid;
171 if (NUIApplication.MultilingualResourceManager == null)
173 throw new ArgumentNullException(null, "ResourceManager about multilingual is null");
175 textFieldPlaceHolderTextSid = value;
176 PlaceholderText = SetTranslatable(textFieldPlaceHolderTextSid);
177 NotifyPropertyChanged();
182 /// The Text property.
184 /// <since_tizen> 3 </since_tizen>
189 return (string)GetValue(TextProperty);
193 SetValueAndForceSendChangeSignal(TextProperty, value);
194 selectorData?.Text?.Reset(this);
195 NotifyPropertyChanged();
200 /// The PlaceholderText property.
202 /// <since_tizen> 3 </since_tizen>
203 public string PlaceholderText
207 return (string)GetValue(PlaceholderTextProperty);
211 SetValue(PlaceholderTextProperty, value);
212 NotifyPropertyChanged();
217 /// The PlaceholderTextFocused property.
219 /// <since_tizen> 3 </since_tizen>
220 public string PlaceholderTextFocused
224 return (string)GetValue(PlaceholderTextFocusedProperty);
228 SetValue(PlaceholderTextFocusedProperty, value);
229 NotifyPropertyChanged();
234 /// The FontFamily property.
236 /// <since_tizen> 3 </since_tizen>
237 public string FontFamily
241 return (string)GetValue(FontFamilyProperty);
245 SetValue(FontFamilyProperty, value);
246 selectorData?.FontFamily?.Reset(this);
247 NotifyPropertyChanged();
252 /// The FontStyle property.
254 /// <since_tizen> 3 </since_tizen>
255 public PropertyMap FontStyle
259 return (PropertyMap)GetValue(FontStyleProperty);
263 SetValue(FontStyleProperty, value);
264 NotifyPropertyChanged();
269 /// The PointSize property.
271 /// <since_tizen> 3 </since_tizen>
272 public float PointSize
276 return (float)GetValue(PointSizeProperty);
280 SetValue(PointSizeProperty, value);
281 selectorData?.PointSize?.Reset(this);
282 NotifyPropertyChanged();
287 /// The MaxLength property.
289 /// <since_tizen> 3 </since_tizen>
294 return (int)GetValue(MaxLengthProperty);
298 SetValue(MaxLengthProperty, value);
299 NotifyPropertyChanged();
304 /// The ExceedPolicy property.
306 /// <since_tizen> 3 </since_tizen>
307 public int ExceedPolicy
311 return (int)GetValue(ExceedPolicyProperty);
315 SetValue(ExceedPolicyProperty, value);
316 NotifyPropertyChanged();
321 /// The HorizontalAlignment property.
323 /// <since_tizen> 3 </since_tizen>
324 public HorizontalAlignment HorizontalAlignment
328 return (HorizontalAlignment)GetValue(HorizontalAlignmentProperty);
332 SetValue(HorizontalAlignmentProperty, value);
333 NotifyPropertyChanged();
338 /// The VerticalAlignment property.
340 /// <since_tizen> 3 </since_tizen>
341 public VerticalAlignment VerticalAlignment
345 return (VerticalAlignment)GetValue(VerticalAlignmentProperty);
349 SetValue(VerticalAlignmentProperty, value);
350 NotifyPropertyChanged();
351 NotifyPropertyChanged();
356 /// The TextColor property.
359 /// The property cascade chaining set is possible. For example, this (textField.TextColor.X = 0.1f;) is possible.
361 /// <since_tizen> 3 </since_tizen>
362 public Color TextColor
366 Color temp = (Color)GetValue(TextColorProperty);
367 return new Color(OnTextColorChanged, temp.R, temp.G, temp.B, temp.A);
371 SetValue(TextColorProperty, value);
372 selectorData?.TextColor?.Reset(this);
373 NotifyPropertyChanged();
378 /// The PlaceholderTextColor property.
381 /// The property cascade chaining set is possible. For example, this (textField.PlaceholderTextColor.X = 0.1f;) is possible.
383 /// <since_tizen> 3 </since_tizen>
384 public Vector4 PlaceholderTextColor
388 Vector4 temp = (Vector4)GetValue(PlaceholderTextColorProperty);
389 return new Vector4(OnPlaceholderTextColorChanged, temp.X, temp.Y, temp.Z, temp.W);
393 SetValue(PlaceholderTextColorProperty, value);
394 selectorData?.PlaceholderTextColor?.Reset(this);
395 NotifyPropertyChanged();
400 /// The ShadowOffset property.
402 /// <since_tizen> 3 </since_tizen>
404 /// Deprecated.(API Level 6) Use Shadow instead.
405 /// The property cascade chaining set is possible. For example, this (textField.ShadowOffset.X = 0.1f;) is possible.
407 [Obsolete("Please do not use this ShadowOffset(Deprecated). Please use Shadow instead.")]
408 public Vector2 ShadowOffset
412 PropertyMap map = new PropertyMap();
413 GetProperty(TextField.Property.SHADOW).Get(map);
414 Vector2 shadowOffset = new Vector2();
415 map.Find(TextField.Property.SHADOW, "offset")?.Get(shadowOffset);
416 return new Vector2(OnShadowOffsetChanged, shadowOffset.X, shadowOffset.Y);
420 PropertyMap temp = new PropertyMap();
421 temp.Insert("offset", new PropertyValue(value));
422 SetValue(ShadowProperty, temp);
423 NotifyPropertyChanged();
428 /// The ShadowColor property.
430 /// <since_tizen> 3 </since_tizen>
432 /// Deprecated.(API Level 6) Use Shadow instead.
433 /// The property cascade chaining set is possible. For example, this (textField.ShadowColor.X = 0.1f;) is possible.
435 [Obsolete("Please do not use this ShadowColor(Deprecated). Please use Shadow instead.")]
436 public Vector4 ShadowColor
440 PropertyMap map = new PropertyMap();
441 GetProperty(TextField.Property.SHADOW).Get(map);
442 Vector4 shadowColor = new Vector4();
443 map.Find(TextField.Property.SHADOW, "color")?.Get(shadowColor);
444 return new Vector4(OnShadowColorChanged, shadowColor.X, shadowColor.Y, shadowColor.Z, shadowColor.W);
448 PropertyMap temp = new PropertyMap();
449 temp.Insert("color", new PropertyValue(value));
450 SetValue(ShadowProperty, temp);
451 NotifyPropertyChanged();
456 /// The PrimaryCursorColor property.
459 /// The property cascade chaining set is possible. For example, this (textField.PrimaryCursorColor.X = 0.1f;) is possible.
461 /// <since_tizen> 3 </since_tizen>
462 public Vector4 PrimaryCursorColor
466 Vector4 temp = (Vector4)GetValue(PrimaryCursorColorProperty);
467 return new Vector4(OnPrimaryCursorColorChanged, temp.X, temp.Y, temp.Z, temp.W);
471 SetValue(PrimaryCursorColorProperty, value);
472 selectorData?.PrimaryCursorColor?.Reset(this);
473 NotifyPropertyChanged();
478 /// The SecondaryCursorColor property.
481 /// The property cascade chaining set is possible. For example, this (textField.SecondaryCursorColor.X = 0.1f;) is possible.
483 /// <since_tizen> 3 </since_tizen>
484 public Vector4 SecondaryCursorColor
488 Vector4 temp = (Vector4)GetValue(SecondaryCursorColorProperty);
489 return new Vector4(OnSecondaryCursorColorChanged, temp.X, temp.Y, temp.Z, temp.W);
493 SetValue(SecondaryCursorColorProperty, value);
494 NotifyPropertyChanged();
499 /// The EnableCursorBlink property.
501 /// <since_tizen> 3 </since_tizen>
502 public bool EnableCursorBlink
506 return (bool)GetValue(EnableCursorBlinkProperty);
510 SetValue(EnableCursorBlinkProperty, value);
511 NotifyPropertyChanged();
516 /// The CursorBlinkInterval property.
518 /// <since_tizen> 3 </since_tizen>
519 public float CursorBlinkInterval
523 return (float)GetValue(CursorBlinkIntervalProperty);
527 SetValue(CursorBlinkIntervalProperty, value);
528 NotifyPropertyChanged();
533 /// The CursorBlinkDuration property.
535 /// <since_tizen> 3 </since_tizen>
536 public float CursorBlinkDuration
540 return (float)GetValue(CursorBlinkDurationProperty);
544 SetValue(CursorBlinkDurationProperty, value);
545 NotifyPropertyChanged();
550 /// The CursorWidth property.
552 /// <since_tizen> 3 </since_tizen>
553 public int CursorWidth
557 return (int)GetValue(CursorWidthProperty);
561 SetValue(CursorWidthProperty, value);
562 NotifyPropertyChanged();
567 /// The GrabHandleImage property.
569 /// <since_tizen> 3 </since_tizen>
570 public string GrabHandleImage
574 return (string)GetValue(GrabHandleImageProperty);
578 SetValue(GrabHandleImageProperty, value);
579 NotifyPropertyChanged();
584 /// The GrabHandlePressedImage property.
586 /// <since_tizen> 3 </since_tizen>
587 public string GrabHandlePressedImage
591 return (string)GetValue(GrabHandlePressedImageProperty);
595 SetValue(GrabHandlePressedImageProperty, value);
596 NotifyPropertyChanged();
601 /// The ScrollThreshold property.
603 /// <since_tizen> 3 </since_tizen>
604 public float ScrollThreshold
608 return (float)GetValue(ScrollThresholdProperty);
612 SetValue(ScrollThresholdProperty, value);
613 NotifyPropertyChanged();
618 /// The ScrollSpeed property.
620 /// <since_tizen> 3 </since_tizen>
621 public float ScrollSpeed
625 return (float)GetValue(ScrollSpeedProperty);
629 SetValue(ScrollSpeedProperty, value);
630 NotifyPropertyChanged();
635 /// The SelectionHandleImageLeft property.
637 /// <since_tizen> 3 </since_tizen>
638 public PropertyMap SelectionHandleImageLeft
642 return (PropertyMap)GetValue(SelectionHandleImageLeftProperty);
646 SetValue(SelectionHandleImageLeftProperty, value);
647 NotifyPropertyChanged();
652 /// The SelectionHandleImageRight property.
654 /// <since_tizen> 3 </since_tizen>
655 public PropertyMap SelectionHandleImageRight
659 return (PropertyMap)GetValue(SelectionHandleImageRightProperty);
663 SetValue(SelectionHandleImageRightProperty, value);
664 NotifyPropertyChanged();
669 /// The SelectionHandlePressedImageLeft property.
671 /// <since_tizen> 3 </since_tizen>
672 public PropertyMap SelectionHandlePressedImageLeft
676 return (PropertyMap)GetValue(SelectionHandlePressedImageLeftProperty);
680 SetValue(SelectionHandlePressedImageLeftProperty, value);
681 NotifyPropertyChanged();
686 /// The SelectionHandlePressedImageRight property.
688 /// <since_tizen> 3 </since_tizen>
689 public PropertyMap SelectionHandlePressedImageRight
693 return (PropertyMap)GetValue(SelectionHandlePressedImageRightProperty);
697 SetValue(SelectionHandlePressedImageRightProperty, value);
698 NotifyPropertyChanged();
703 /// The SelectionHandleMarkerImageLeft property.
705 /// <since_tizen> 3 </since_tizen>
706 public PropertyMap SelectionHandleMarkerImageLeft
710 return (PropertyMap)GetValue(SelectionHandleMarkerImageLeftProperty);
714 SetValue(SelectionHandleMarkerImageLeftProperty, value);
715 NotifyPropertyChanged();
720 /// The SelectionHandleMarkerImageRight property.
722 /// <since_tizen> 3 </since_tizen>
723 public PropertyMap SelectionHandleMarkerImageRight
727 return (PropertyMap)GetValue(SelectionHandleMarkerImageRightProperty);
731 SetValue(SelectionHandleMarkerImageRightProperty, value);
732 NotifyPropertyChanged();
737 /// The SelectionHighlightColor property.
740 /// The property cascade chaining set is possible. For example, this (textField.SelectionHighlightColor.X = 0.1f;) is possible.
742 /// <since_tizen> 3 </since_tizen>
743 public Vector4 SelectionHighlightColor
747 Vector4 temp = (Vector4)GetValue(SelectionHighlightColorProperty);
748 return new Vector4(OnSelectionHighlightColorChanged, temp.X, temp.Y, temp.Z, temp.W);
752 SetValue(SelectionHighlightColorProperty, value);
753 NotifyPropertyChanged();
758 /// The DecorationBoundingBox property.
761 /// The property cascade chaining set is possible. For example, this (textField.DecorationBoundingBox.X = 0.1f;) is possible.
763 /// <since_tizen> 3 </since_tizen>
764 public Rectangle DecorationBoundingBox
768 Rectangle temp = (Rectangle)GetValue(DecorationBoundingBoxProperty);
769 return new Rectangle(OnDecorationBoundingBoxChanged, temp.X, temp.Y, temp.Width, temp.Height);
773 SetValue(DecorationBoundingBoxProperty, value);
774 NotifyPropertyChanged();
779 /// The InputMethodSettings property.
781 /// <since_tizen> 3 </since_tizen>
782 public PropertyMap InputMethodSettings
786 return (PropertyMap)GetValue(InputMethodSettingsProperty);
790 SetValue(InputMethodSettingsProperty, value);
791 NotifyPropertyChanged();
796 /// The InputColor property.
799 /// The property cascade chaining set is possible. For example, this (textField.InputColor.X = 0.1f;) is possible.
801 /// <since_tizen> 3 </since_tizen>
802 public Vector4 InputColor
806 Vector4 temp = (Vector4)GetValue(InputColorProperty);
807 return new Vector4(OnInputColorChanged, temp.X, temp.Y, temp.Z, temp.W);
811 SetValue(InputColorProperty, value);
812 NotifyPropertyChanged();
817 /// The EnableMarkup property.
819 /// <since_tizen> 3 </since_tizen>
820 public bool EnableMarkup
824 return (bool)GetValue(EnableMarkupProperty);
828 SetValue(EnableMarkupProperty, value);
829 NotifyPropertyChanged();
834 /// The InputFontFamily property.
836 /// <since_tizen> 3 </since_tizen>
837 public string InputFontFamily
841 return (string)GetValue(InputFontFamilyProperty);
845 SetValue(InputFontFamilyProperty, value);
846 NotifyPropertyChanged();
851 /// The InputFontStyle property.
853 /// <since_tizen> 3 </since_tizen>
854 public PropertyMap InputFontStyle
858 return (PropertyMap)GetValue(InputFontStyleProperty);
862 SetValue(InputFontStyleProperty, value);
863 NotifyPropertyChanged();
868 /// The InputPointSize property.
870 /// <since_tizen> 3 </since_tizen>
871 public float InputPointSize
875 return (float)GetValue(InputPointSizeProperty);
879 SetValue(InputPointSizeProperty, value);
880 NotifyPropertyChanged();
885 /// The Underline property.
887 /// <since_tizen> 3 </since_tizen>
888 public PropertyMap Underline
892 return (PropertyMap)GetValue(UnderlineProperty);
896 SetValue(UnderlineProperty, value);
897 NotifyPropertyChanged();
902 /// The InputUnderline property.
904 /// <since_tizen> 3 </since_tizen>
905 public string InputUnderline
909 return (string)GetValue(InputUnderlineProperty);
913 SetValue(InputUnderlineProperty, value);
914 NotifyPropertyChanged();
919 /// The Shadow property.
921 /// <since_tizen> 3 </since_tizen>
922 public PropertyMap Shadow
926 return (PropertyMap)GetValue(ShadowProperty);
930 SetValue(ShadowProperty, value);
931 NotifyPropertyChanged();
936 /// The InputShadow property.
938 /// <since_tizen> 3 </since_tizen>
939 public string InputShadow
943 return (string)GetValue(InputShadowProperty);
947 SetValue(InputShadowProperty, value);
948 NotifyPropertyChanged();
953 /// The Emboss property.
955 /// <since_tizen> 3 </since_tizen>
960 return (string)GetValue(EmbossProperty);
964 SetValue(EmbossProperty, value);
965 NotifyPropertyChanged();
970 /// The InputEmboss property.
972 /// <since_tizen> 3 </since_tizen>
973 public string InputEmboss
977 return (string)GetValue(InputEmbossProperty);
981 SetValue(InputEmbossProperty, value);
982 NotifyPropertyChanged();
987 /// The Outline property.
989 /// <since_tizen> 3 </since_tizen>
990 public PropertyMap Outline
994 return (PropertyMap)GetValue(OutlineProperty);
998 SetValue(OutlineProperty, value);
999 NotifyPropertyChanged();
1004 /// The InputOutline property.
1006 /// <since_tizen> 3 </since_tizen>
1007 public string InputOutline
1011 return (string)GetValue(InputOutlineProperty);
1015 SetValue(InputOutlineProperty, value);
1016 NotifyPropertyChanged();
1021 /// The HiddenInputSettings property.
1023 /// <since_tizen> 3 </since_tizen>
1024 public Tizen.NUI.PropertyMap HiddenInputSettings
1028 return (PropertyMap)GetValue(HiddenInputSettingsProperty);
1032 SetValue(HiddenInputSettingsProperty, value);
1033 NotifyPropertyChanged();
1038 /// The PixelSize property.
1040 /// <since_tizen> 3 </since_tizen>
1041 public float PixelSize
1045 return (float)GetValue(PixelSizeProperty);
1049 SetValue(PixelSizeProperty, value);
1050 selectorData?.PixelSize?.Reset(this);
1051 NotifyPropertyChanged();
1056 /// The Enable selection property.
1058 /// <since_tizen> 3 </since_tizen>
1059 public bool EnableSelection
1063 return (bool)GetValue(EnableSelectionProperty);
1067 SetValue(EnableSelectionProperty, value);
1068 NotifyPropertyChanged();
1073 /// The Enable selection property.
1075 /// <since_tizen> 6 </since_tizen>
1076 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
1077 [EditorBrowsable(EditorBrowsableState.Never)]
1078 public bool EnableGrabHandle
1082 return (bool)GetValue(EnableGrabHandleProperty);
1086 SetValue(EnableGrabHandleProperty, value);
1087 NotifyPropertyChanged();
1092 /// The Enable selection property.
1094 /// <since_tizen> 6 </since_tizen>
1095 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
1096 [EditorBrowsable(EditorBrowsableState.Never)]
1097 public bool EnableGrabHandlePopup
1101 return (bool)GetValue(EnableGrabHandlePopupProperty);
1105 SetValue(EnableGrabHandlePopupProperty, value);
1106 NotifyPropertyChanged();
1111 /// The Selected Text property.
1113 /// <since_tizen> 8 </since_tizen>
1114 /// This will be public opened in tizen_6.0 after ACR done, Before ACR, need to be hidden as inhouse API.
1115 [EditorBrowsable(EditorBrowsableState.Never)]
1116 public string SelectedText
1121 GetProperty(TextField.Property.SelectedText).Get(out temp);
1127 /// The start index for selection.
1129 /// <since_tizen> 8 </since_tizen>
1130 /// This will be public opened in tizen_6.0 after ACR done, Before ACR, need to be hidden as inhouse API.
1131 [EditorBrowsable(EditorBrowsableState.Never)]
1132 public int SelectedTextStart
1137 GetProperty(TextField.Property.SelectedTextStart).Get(out temp);
1142 SetProperty(TextField.Property.SelectedTextStart, new PropertyValue(value));
1143 NotifyPropertyChanged();
1148 /// The end index for selection.
1150 /// <since_tizen> 8 </since_tizen>
1151 /// This will be public opened in tizen_6.0 after ACR done, Before ACR, need to be hidden as inhouse API.
1152 [EditorBrowsable(EditorBrowsableState.Never)]
1153 public int SelectedTextEnd
1158 GetProperty(TextField.Property.SelectedTextEnd).Get(out temp);
1163 SetProperty(TextField.Property.SelectedTextEnd, new PropertyValue(value));
1164 NotifyPropertyChanged();
1169 /// Enable editing in text control.
1171 /// <since_tizen> 8 </since_tizen>
1172 /// This will be public opened in tizen_6.0 after ACR done, Before ACR, need to be hidden as inhouse API.
1173 [EditorBrowsable(EditorBrowsableState.Never)]
1174 public bool EnableEditing
1179 GetProperty(TextField.Property.EnableEditing).Get(out temp);
1184 SetProperty(TextField.Property.EnableEditing, new PropertyValue(value));
1185 NotifyPropertyChanged();
1190 /// Specify primary cursor (caret) position in text control.
1192 [EditorBrowsable(EditorBrowsableState.Never)]
1193 public int PrimaryCursorPosition
1198 using (PropertyValue propertyValue = GetProperty(TextField.Property.PrimaryCursorPosition))
1200 propertyValue.Get(out temp);
1206 using (PropertyValue propertyValue = new PropertyValue(value))
1208 SetProperty(TextField.Property.PrimaryCursorPosition, propertyValue);
1209 NotifyPropertyChanged();
1215 /// The Placeholder property.
1216 /// Gets or sets the placeholder: text, color, font family, font style, point size, and pixel size.
1219 /// The following example demonstrates how to set the Placeholder property.
1221 /// PropertyMap propertyMap = new PropertyMap();
1222 /// propertyMap.Add("text", new PropertyValue("Setting Placeholder Text"));
1223 /// propertyMap.Add("textFocused", new PropertyValue("Setting Placeholder Text Focused"));
1224 /// propertyMap.Add("color", new PropertyValue(Color.Red));
1225 /// propertyMap.Add("fontFamily", new PropertyValue("Arial"));
1226 /// propertyMap.Add("pointSize", new PropertyValue(12.0f));
1228 /// PropertyMap fontStyleMap = new PropertyMap();
1229 /// fontStyleMap.Add("weight", new PropertyValue("bold"));
1230 /// fontStyleMap.Add("width", new PropertyValue("condensed"));
1231 /// fontStyleMap.Add("slant", new PropertyValue("italic"));
1232 /// propertyMap.Add("fontStyle", new PropertyValue(fontStyleMap));
1234 /// TextField field = new TextField();
1235 /// field.Placeholder = propertyMap;
1238 /// <since_tizen> 3 </since_tizen>
1239 public Tizen.NUI.PropertyMap Placeholder
1243 return (PropertyMap)GetValue(PlaceholderProperty);
1247 SetValue(PlaceholderProperty, value);
1248 NotifyPropertyChanged();
1253 /// The Ellipsis property.<br />
1254 /// Enable or disable the ellipsis.<br />
1255 /// Placeholder PropertyMap is used to add ellipsis to placeholder text.
1257 /// <since_tizen> 4 </since_tizen>
1258 public bool Ellipsis
1262 return (bool)GetValue(EllipsisProperty);
1266 SetValue(EllipsisProperty, value);
1267 NotifyPropertyChanged();
1272 /// Enables selection of the text using the Shift key.
1274 /// <since_tizen> 5 </since_tizen>
1275 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
1276 [EditorBrowsable(EditorBrowsableState.Never)]
1277 public bool EnableShiftSelection
1281 return (bool)GetValue(EnableShiftSelectionProperty);
1285 SetValue(EnableShiftSelectionProperty, value);
1286 NotifyPropertyChanged();
1291 /// The text alignment to match the direction of the system language.
1293 /// <since_tizen> 6 </since_tizen>
1294 public bool MatchSystemLanguageDirection
1298 return (bool)GetValue(MatchSystemLanguageDirectionProperty);
1302 SetValue(MatchSystemLanguageDirectionProperty, value);
1303 NotifyPropertyChanged();
1308 /// The FontSizeScale property. <br />
1309 /// The default value is 1.0. <br />
1310 /// If FontSizeScale.UseSystemSetting, will use the SystemSettings.FontSize internally. <br />
1312 /// <since_tizen> 9 </since_tizen>
1313 public float FontSizeScale
1317 return fontSizeScale;
1321 float newFontSizeScale;
1323 if (fontSizeScale == value) return;
1325 fontSizeScale = value;
1326 if (fontSizeScale == Tizen.NUI.FontSizeScale.UseSystemSetting)
1328 SystemSettingsFontSize systemSettingsFontSize;
1332 systemSettingsFontSize = SystemSettings.FontSize;
1336 Console.WriteLine("{0} Exception caught.", e);
1337 systemSettingsFontSize = SystemSettingsFontSize.Normal;
1339 newFontSizeScale = TextUtils.GetFontSizeScale(systemSettingsFontSize);
1340 addFontSizeChangedCallback();
1344 newFontSizeScale = fontSizeScale;
1345 removeFontSizeChangedCallback();
1348 SetValue(FontSizeScaleProperty, newFontSizeScale);
1349 NotifyPropertyChanged();
1353 /// Only used by the IL of xaml, will never changed to not hidden.
1354 [EditorBrowsable(EditorBrowsableState.Never)]
1355 public override bool IsCreateByXaml
1359 return base.IsCreateByXaml;
1363 base.IsCreateByXaml = value;
1367 this.TextChanged += (obj, e) =>
1369 this.Text = e.TextField.Text;
1375 private TextFieldSelectorData EnsureSelectorData() => selectorData ?? (selectorData = new TextFieldSelectorData());
1378 /// Get the InputMethodContext instance.
1380 /// <returns>The InputMethodContext instance.</returns>
1381 /// <since_tizen> 5 </since_tizen>
1382 public InputMethodContext GetInputMethodContext()
1384 if (inputMethodCotext == null)
1386 /*Avoid raising InputMethodContext reference count.*/
1387 inputMethodCotext = new InputMethodContext(Interop.TextField.GetInputMethodContext(SwigCPtr), true);
1388 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1390 return inputMethodCotext;
1394 /// Select the whole text.
1396 /// <since_tizen> 6 </since_tizen>
1397 /// This will be released at Tizen.NET API Level 5.5, so currently this would be used as inhouse API.
1398 [EditorBrowsable(EditorBrowsableState.Never)]
1399 public void SelectWholeText()
1401 Interop.TextField.SelectWholeText(SwigCPtr);
1402 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1406 /// Clear selection of the text.
1408 /// <since_tizen> 8 </since_tizen>
1409 /// This will be public opened in tizen_6.0 after ACR done, Before ACR, need to be hidden as inhouse API.
1410 [EditorBrowsable(EditorBrowsableState.Never)]
1411 public void SelectNone()
1413 _ = Interop.TextField.SelectNone(SwigCPtr);
1414 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1417 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TextField obj)
1419 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
1422 internal SWIGTYPE_p_Dali__SignalT_void_fDali__Toolkit__TextField_Dali__Toolkit__TextField__InputStyle__MaskF_t InputStyleChangedSignal()
1424 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));
1425 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1432 /// <since_tizen> 3 </since_tizen>
1433 protected override void Dispose(DisposeTypes type)
1437 DisposeQueue.Instance.Add(this);
1441 if (systemlangTextFlag)
1443 SystemSettings.LocaleLanguageChanged -= SystemSettings_LocaleLanguageChanged;
1446 removeFontSizeChangedCallback();
1448 if (type == DisposeTypes.Explicit)
1451 //Release your own managed resources here.
1452 //You should release all of your own disposable objects here.
1453 selectorData?.Reset(this);
1456 //Release your own unmanaged resources here.
1457 //You should not access any managed member here except static instance.
1458 //because the execution order of Finalizes is non-deterministic.
1461 if (textFieldMaxLengthReachedCallbackDelegate != null)
1463 this.MaxLengthReachedSignal().Disconnect(textFieldMaxLengthReachedCallbackDelegate);
1466 if (textFieldTextChangedCallbackDelegate != null)
1468 TextChangedSignal().Disconnect(textFieldTextChangedCallbackDelegate);
1475 /// This will not be public opened.
1476 [EditorBrowsable(EditorBrowsableState.Never)]
1477 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1479 // In order to speed up IME hide, temporarily add
1480 GetInputMethodContext()?.DestroyContext();
1481 Interop.TextField.DeleteTextField(swigCPtr);
1484 private string SetTranslatable(string textFieldSid)
1486 string translatableText = null;
1487 translatableText = NUIApplication.MultilingualResourceManager?.GetString(textFieldSid, new CultureInfo(SystemSettings.LocaleLanguage.Replace("_", "-")));
1488 if (translatableText != null)
1490 if (systemlangTextFlag == false)
1492 SystemSettings.LocaleLanguageChanged += SystemSettings_LocaleLanguageChanged;
1493 systemlangTextFlag = true;
1495 return translatableText;
1499 translatableText = "";
1500 return translatableText;
1504 private void SystemSettings_LocaleLanguageChanged(object sender, LocaleLanguageChangedEventArgs e)
1506 if (textFieldTextSid != null)
1508 Text = NUIApplication.MultilingualResourceManager?.GetString(textFieldTextSid, new CultureInfo(e.Value.Replace("_", "-")));
1510 if (textFieldPlaceHolderTextSid != null)
1512 PlaceholderText = NUIApplication.MultilingualResourceManager?.GetString(textFieldPlaceHolderTextSid, new CultureInfo(e.Value.Replace("_", "-")));
1516 private void SystemSettingsFontSizeChanged(object sender, FontSizeChangedEventArgs e)
1518 float newFontSizeScale = TextUtils.GetFontSizeScale(e.Value);
1519 SetValue(FontSizeScaleProperty, newFontSizeScale);
1520 NotifyPropertyChanged();
1523 private void addFontSizeChangedCallback()
1525 if (hasFontSizeChangedCallback != true)
1529 SystemSettings.FontSizeChanged += SystemSettingsFontSizeChanged;
1530 hasFontSizeChangedCallback = true;
1534 Console.WriteLine("{0} Exception caught.", e);
1535 hasFontSizeChangedCallback = false;
1540 private void removeFontSizeChangedCallback()
1542 if (hasFontSizeChangedCallback == true)
1546 SystemSettings.FontSizeChanged -= SystemSettingsFontSizeChanged;
1547 hasFontSizeChangedCallback = false;
1551 Console.WriteLine("{0} Exception caught.", e);
1552 hasFontSizeChangedCallback = true;
1557 internal new class Property
1559 internal static readonly int TEXT = Interop.TextField.TextGet();
1560 internal static readonly int PlaceholderText = Interop.TextField.PlaceholderTextGet();
1561 internal static readonly int PlaceholderTextFocused = Interop.TextField.PlaceholderTextFocusedGet();
1562 internal static readonly int FontFamily = Interop.TextField.FontFamilyGet();
1563 internal static readonly int FontStyle = Interop.TextField.FontStyleGet();
1564 internal static readonly int PointSize = Interop.TextField.PointSizeGet();
1565 internal static readonly int MaxLength = Interop.TextField.MaxLengthGet();
1566 internal static readonly int ExceedPolicy = Interop.TextField.ExceedPolicyGet();
1567 internal static readonly int HorizontalAlignment = Interop.TextField.HorizontalAlignmentGet();
1568 internal static readonly int VerticalAlignment = Interop.TextField.VerticalAlignmentGet();
1569 internal static readonly int TextColor = Interop.TextField.TextColorGet();
1570 internal static readonly int PlaceholderTextColor = Interop.TextField.PlaceholderTextColorGet();
1571 internal static readonly int PrimaryCursorColor = Interop.TextField.PrimaryCursorColorGet();
1572 internal static readonly int SecondaryCursorColor = Interop.TextField.SecondaryCursorColorGet();
1573 internal static readonly int EnableCursorBlink = Interop.TextField.EnableCursorBlinkGet();
1574 internal static readonly int CursorBlinkInterval = Interop.TextField.CursorBlinkIntervalGet();
1575 internal static readonly int CursorBlinkDuration = Interop.TextField.CursorBlinkDurationGet();
1576 internal static readonly int CursorWidth = Interop.TextField.CursorWidthGet();
1577 internal static readonly int GrabHandleImage = Interop.TextField.GrabHandleImageGet();
1578 internal static readonly int GrabHandlePressedImage = Interop.TextField.GrabHandlePressedImageGet();
1579 internal static readonly int ScrollThreshold = Interop.TextField.ScrollThresholdGet();
1580 internal static readonly int ScrollSpeed = Interop.TextField.ScrollSpeedGet();
1581 internal static readonly int SelectionHandleImageLeft = Interop.TextField.SelectionHandleImageLeftGet();
1582 internal static readonly int SelectionHandleImageRight = Interop.TextField.SelectionHandleImageRightGet();
1583 internal static readonly int SelectionHandlePressedImageLeft = Interop.TextField.SelectionHandlePressedImageLeftGet();
1584 internal static readonly int SelectionHandlePressedImageRight = Interop.TextField.SelectionHandlePressedImageRightGet();
1585 internal static readonly int SelectionHandleMarkerImageLeft = Interop.TextField.SelectionHandleMarkerImageLeftGet();
1586 internal static readonly int SelectionHandleMarkerImageRight = Interop.TextField.SelectionHandleMarkerImageRightGet();
1587 internal static readonly int SelectionHighlightColor = Interop.TextField.SelectionHighlightColorGet();
1588 internal static readonly int DecorationBoundingBox = Interop.TextField.DecorationBoundingBoxGet();
1589 internal static readonly int InputMethodSettings = Interop.TextField.InputMethodSettingsGet();
1590 internal static readonly int InputColor = Interop.TextField.InputColorGet();
1591 internal static readonly int EnableMarkup = Interop.TextField.EnableMarkupGet();
1592 internal static readonly int InputFontFamily = Interop.TextField.InputFontFamilyGet();
1593 internal static readonly int InputFontStyle = Interop.TextField.InputFontStyleGet();
1594 internal static readonly int InputPointSize = Interop.TextField.InputPointSizeGet();
1595 internal static readonly int UNDERLINE = Interop.TextField.UnderlineGet();
1596 internal static readonly int InputUnderline = Interop.TextField.InputUnderlineGet();
1597 internal static readonly int SHADOW = Interop.TextField.ShadowGet();
1598 internal static readonly int InputShadow = Interop.TextField.InputShadowGet();
1599 internal static readonly int EMBOSS = Interop.TextField.EmbossGet();
1600 internal static readonly int InputEmboss = Interop.TextField.InputEmbossGet();
1601 internal static readonly int OUTLINE = Interop.TextField.OutlineGet();
1602 internal static readonly int InputOutline = Interop.TextField.InputOutlineGet();
1603 internal static readonly int HiddenInputSettings = Interop.TextField.HiddenInputSettingsGet();
1604 internal static readonly int PixelSize = Interop.TextField.PixelSizeGet();
1605 internal static readonly int EnableSelection = Interop.TextField.EnableSelectionGet();
1606 internal static readonly int PLACEHOLDER = Interop.TextField.PlaceholderGet();
1607 internal static readonly int ELLIPSIS = Interop.TextField.EllipsisGet();
1608 internal static readonly int EnableShiftSelection = Interop.TextField.EnableShiftSelectionGet();
1609 internal static readonly int MatchSystemLanguageDirection = Interop.TextField.MatchSystemLanguageDirectionGet();
1610 internal static readonly int EnableGrabHandle = Interop.TextField.EnableGrabHandleGet();
1611 internal static readonly int EnableGrabHandlePopup = Interop.TextField.EnableGrabHandlePopupGet();
1612 internal static readonly int SelectedText = Interop.TextField.SelectedTextGet();
1613 internal static readonly int SelectedTextStart = Interop.TextField.SelectedTextStartGet();
1614 internal static readonly int SelectedTextEnd = Interop.TextField.SelectedTextEndGet();
1615 internal static readonly int EnableEditing = Interop.TextField.EnableEditingGet();
1616 internal static readonly int PrimaryCursorPosition = Interop.TextField.PrimaryCursorPositionGet();
1617 internal static readonly int FontSizeScale = Interop.TextField.FontSizeScaleGet();
1620 internal class InputStyle
1626 FontFamily = 0x0002,
1636 private void OnDecorationBoundingBoxChanged(int x, int y, int width, int height)
1638 DecorationBoundingBox = new Rectangle(x, y, width, height);
1640 private void OnInputColorChanged(float x, float y, float z, float w)
1642 InputColor = new Vector4(x, y, z, w);
1644 private void OnPlaceholderTextColorChanged(float r, float g, float b, float a)
1646 PlaceholderTextColor = new Vector4(r, g, b, a);
1648 private void OnPrimaryCursorColorChanged(float x, float y, float z, float w)
1650 PrimaryCursorColor = new Vector4(x, y, z, w);
1652 private void OnSecondaryCursorColorChanged(float x, float y, float z, float w)
1654 SecondaryCursorColor = new Vector4(x, y, z, w);
1656 private void OnSelectionHighlightColorChanged(float x, float y, float z, float w)
1658 SelectionHighlightColor = new Vector4(x, y, z, w);
1660 private void OnShadowColorChanged(float x, float y, float z, float w)
1662 ShadowColor = new Vector4(x, y, z, w);
1664 private void OnShadowOffsetChanged(float x, float y)
1666 ShadowOffset = new Vector2(x, y);
1668 private void OnTextColorChanged(float r, float g, float b, float a)
1670 TextColor = new Color(r, g, b, a);