2 * Copyright(c) 2021 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.
18 extern alias TizenSystemSettings;
19 using TizenSystemSettings.Tizen.System;
22 using System.Globalization;
23 using System.ComponentModel;
25 namespace Tizen.NUI.BaseComponents
28 /// A control which provides a multi-line editable text editor.
30 /// <since_tizen> 3 </since_tizen>
31 public partial class TextEditor : View
33 private string textEditorTextSid = null;
34 private string textEditorPlaceHolderTextSid = null;
35 private bool systemlangTextFlag = false;
36 private InputMethodContext inputMethodContext = null;
37 private float fontSizeScale = 1.0f;
38 private bool hasFontSizeChangedCallback = false;
40 static TextEditor() { }
43 /// Creates the TextEditor control.
45 /// <since_tizen> 3 </since_tizen>
46 public TextEditor() : this(Interop.TextEditor.New(), true)
48 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
52 /// Creates the TextEditor with specified style.
54 [EditorBrowsable(EditorBrowsableState.Never)]
55 public TextEditor(TextEditorStyle style) : this(Interop.TextLabel.New(), true, style: style)
60 /// Creates the TextEditor with setting the status of shown or hidden.
62 /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
63 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
64 [EditorBrowsable(EditorBrowsableState.Never)]
65 public TextEditor(bool shown) : this(Interop.TextEditor.New(), true)
67 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
71 internal TextEditor(TextEditor handle, bool shown = true) : this(Interop.TextEditor.NewTextEditor(TextEditor.getCPtr(handle)), true)
73 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
81 internal TextEditor(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true, TextEditorStyle style = null) : base(cPtr, cMemoryOwn, style)
90 /// The TranslatableText property.<br />
91 /// The text can set the SID value.<br />
93 /// <exception cref='ArgumentNullException'>
94 /// ResourceManager about multilingual is null.
96 /// <since_tizen> 4 </since_tizen>
97 public string TranslatableText
101 return textEditorTextSid;
105 if (NUIApplication.MultilingualResourceManager == null)
107 throw new ArgumentNullException(null, "ResourceManager about multilingual is null");
109 textEditorTextSid = value;
110 Text = SetTranslatable(textEditorTextSid);
111 NotifyPropertyChanged();
115 /// The TranslatablePlaceholderText property.<br />
116 /// The text can set the SID value.<br />
118 /// <exception cref='ArgumentNullException'>
119 /// ResourceManager about multilingual is null.
121 /// <since_tizen> 4 </since_tizen>
122 public string TranslatablePlaceholderText
126 return textEditorPlaceHolderTextSid;
130 if (NUIApplication.MultilingualResourceManager == null)
132 throw new ArgumentNullException(null, "ResourceManager about multilingual is null");
134 textEditorPlaceHolderTextSid = value;
135 PlaceholderText = SetTranslatable(textEditorPlaceHolderTextSid);
136 NotifyPropertyChanged();
141 /// The Text property.
143 /// <since_tizen> 3 </since_tizen>
148 return (string)GetValue(TextProperty);
152 SetValueAndForceSendChangeSignal(TextProperty, value);
153 NotifyPropertyChanged();
158 /// The TextColor property.
161 /// The property cascade chaining set is possible. For example, this (textEditor.TextColor.X = 0.1f;) is possible.
163 /// <since_tizen> 3 </since_tizen>
164 public Vector4 TextColor
168 Vector4 temp = (Vector4)GetValue(TextColorProperty);
169 return new Vector4(OnTextColorChanged, temp.X, temp.Y, temp.Z, temp.W);
173 SetValue(TextColorProperty, value);
174 NotifyPropertyChanged();
179 /// The FontFamily property.
181 /// <since_tizen> 3 </since_tizen>
182 public string FontFamily
186 return (string)GetValue(FontFamilyProperty);
190 SetValue(FontFamilyProperty, value);
191 NotifyPropertyChanged();
196 /// The FontStyle property.
197 /// The fontStyle map contains the following keys :<br />
198 /// <list type="table">
199 /// <item><term>width (string)</term><description>The width key defines occupied by each glyph. (values: ultraCondensed, extraCondensed, condensed, semiCondensed, normal, semiExpanded, expanded, extraExpanded, ultraExpanded)</description></item>
200 /// <item><term>weight (string)</term><description>The weight key defines the thickness or darkness of the glyphs. (values: thin, ultraLight, extraLight, light, demiLight, semiLight, book, normal, regular, medium, demiBold, semiBold, bold, ultraBold, extraBold, black, heavy, extraBlack)</description></item>
201 /// <item><term>slant (string)</term><description>The slant key defines whether to use italics. (values: normal, roman, italic, oblique)</description></item>
204 /// <since_tizen> 3 </since_tizen>
205 public PropertyMap FontStyle
209 return (PropertyMap)GetValue(FontStyleProperty);
213 SetValue(FontStyleProperty, value);
214 NotifyPropertyChanged();
219 /// The PointSize property.
221 /// <since_tizen> 3 </since_tizen>
222 public float PointSize
226 return (float)GetValue(PointSizeProperty);
230 SetValue(PointSizeProperty, value);
231 NotifyPropertyChanged();
236 /// The HorizontalAlignment property.
238 /// <since_tizen> 3 </since_tizen>
239 public HorizontalAlignment HorizontalAlignment
243 return (HorizontalAlignment)GetValue(HorizontalAlignmentProperty);
247 SetValue(HorizontalAlignmentProperty, value);
248 NotifyPropertyChanged();
253 /// The ScrollThreshold property.
255 /// <since_tizen> 3 </since_tizen>
256 public float ScrollThreshold
260 return (float)GetValue(ScrollThresholdProperty);
264 SetValue(ScrollThresholdProperty, value);
265 NotifyPropertyChanged();
270 /// The ScrollSpeed property.
272 /// <since_tizen> 3 </since_tizen>
273 public float ScrollSpeed
277 return (float)GetValue(ScrollSpeedProperty);
281 SetValue(ScrollSpeedProperty, value);
282 NotifyPropertyChanged();
287 /// The PrimaryCursorColor property.
290 /// The property cascade chaining set is possible. For example, this (textEditor.PrimaryCursorColor.X = 0.1f;) is possible.
292 /// <since_tizen> 3 </since_tizen>
293 public Vector4 PrimaryCursorColor
297 Vector4 temp = (Vector4)GetValue(PrimaryCursorColorProperty);
298 return new Vector4(OnPrimaryCursorColorChanged, temp.X, temp.Y, temp.Z, temp.W);
302 SetValue(PrimaryCursorColorProperty, value);
303 NotifyPropertyChanged();
308 /// The SecondaryCursorColor property.
311 /// The property cascade chaining set is possible. For example, this (textEditor.SecondaryCursorColor.X = 0.1f;) is possible.
313 /// <since_tizen> 3 </since_tizen>
314 public Vector4 SecondaryCursorColor
318 Vector4 temp = (Vector4)GetValue(SecondaryCursorColorProperty);
319 return new Vector4(OnSecondaryCursorColorChanged, temp.X, temp.Y, temp.Z, temp.W);
323 SetValue(SecondaryCursorColorProperty, value);
324 NotifyPropertyChanged();
329 /// The EnableCursorBlink property.
331 /// <since_tizen> 3 </since_tizen>
332 public bool EnableCursorBlink
336 return (bool)GetValue(EnableCursorBlinkProperty);
340 SetValue(EnableCursorBlinkProperty, value);
341 NotifyPropertyChanged();
346 /// The CursorBlinkInterval property.
348 /// <since_tizen> 3 </since_tizen>
349 public float CursorBlinkInterval
353 return (float)GetValue(CursorBlinkIntervalProperty);
357 SetValue(CursorBlinkIntervalProperty, value);
358 NotifyPropertyChanged();
363 /// The CursorBlinkDuration property.
365 /// <since_tizen> 3 </since_tizen>
366 public float CursorBlinkDuration
370 return (float)GetValue(CursorBlinkDurationProperty);
374 SetValue(CursorBlinkDurationProperty, value);
375 NotifyPropertyChanged();
380 /// The CursorWidth property.
382 /// <since_tizen> 3 </since_tizen>
383 public int CursorWidth
387 return (int)GetValue(CursorWidthProperty);
391 SetValue(CursorWidthProperty, value);
392 NotifyPropertyChanged();
397 /// The GrabHandleImage property.
399 /// <since_tizen> 3 </since_tizen>
400 public string GrabHandleImage
404 return (string)GetValue(GrabHandleImageProperty);
408 SetValue(GrabHandleImageProperty, value);
409 NotifyPropertyChanged();
414 /// The GrabHandlePressedImage property.
416 /// <since_tizen> 3 </since_tizen>
417 public string GrabHandlePressedImage
421 return (string)GetValue(GrabHandlePressedImageProperty);
425 SetValue(GrabHandlePressedImageProperty, value);
426 NotifyPropertyChanged();
431 /// The SelectionHandleImageLeft property.
432 /// The selectionHandleImageLeft map contains the following key :<br />
433 /// <list type="table">
434 /// <item><term>filename (string)</term><description>The path of image file</description></item>
437 /// <since_tizen> 3 </since_tizen>
438 public PropertyMap SelectionHandleImageLeft
442 return (PropertyMap)GetValue(SelectionHandleImageLeftProperty);
446 SetValue(SelectionHandleImageLeftProperty, value);
447 NotifyPropertyChanged();
452 /// The SelectionHandleImageRight property.
453 /// The selectionHandleImageRight map contains the following key :<br />
454 /// <list type="table">
455 /// <item><term>filename (string)</term><description>The path of image file</description></item>
458 /// <since_tizen> 3 </since_tizen>
459 public PropertyMap SelectionHandleImageRight
463 return (PropertyMap)GetValue(SelectionHandleImageRightProperty);
467 SetValue(SelectionHandleImageRightProperty, value);
468 NotifyPropertyChanged();
473 /// The SelectionHandlePressedImageLeft property.
474 /// The selectionHandlePressedImageLeft map contains the following key :<br />
475 /// <list type="table">
476 /// <item><term>filename (string)</term><description>The path of image file</description></item>
479 /// <since_tizen> 3 </since_tizen>
480 public PropertyMap SelectionHandlePressedImageLeft
484 return (PropertyMap)GetValue(SelectionHandlePressedImageLeftProperty);
488 SetValue(SelectionHandlePressedImageLeftProperty, value);
489 NotifyPropertyChanged();
494 /// The SelectionHandlePressedImageRight property.
495 /// The selectionHandlePressedImageRight map contains the following key :<br />
496 /// <list type="table">
497 /// <item><term>filename (string)</term><description>The path of image file</description></item>
500 /// <since_tizen> 3 </since_tizen>
501 public PropertyMap SelectionHandlePressedImageRight
505 return (PropertyMap)GetValue(SelectionHandlePressedImageRightProperty);
509 SetValue(SelectionHandlePressedImageRightProperty, value);
510 NotifyPropertyChanged();
515 /// The SelectionHandleMarkerImageLeft property.
516 /// The selectionHandleMarkerImageLeft map contains the following key :<br />
517 /// <list type="table">
518 /// <item><term>filename (string)</term><description>The path of image file</description></item>
521 /// <since_tizen> 3 </since_tizen>
522 public PropertyMap SelectionHandleMarkerImageLeft
526 return (PropertyMap)GetValue(SelectionHandleMarkerImageLeftProperty);
530 SetValue(SelectionHandleMarkerImageLeftProperty, value);
531 NotifyPropertyChanged();
536 /// The SelectionHandleMarkerImageRight property.
537 /// The selectionHandleMarkerImageRight map contains the following key :<br />
538 /// <list type="table">
539 /// <item><term>filename (string)</term><description>The path of image file</description></item>
542 /// <since_tizen> 3 </since_tizen>
543 public PropertyMap SelectionHandleMarkerImageRight
547 return (PropertyMap)GetValue(SelectionHandleMarkerImageRightProperty);
551 SetValue(SelectionHandleMarkerImageRightProperty, value);
552 NotifyPropertyChanged();
557 /// The SelectionHighlightColor property.
560 /// The property cascade chaining set is possible. For example, this (textEditor.SelectionHighlightColor.X = 0.1f;) is possible.
562 /// <since_tizen> 3 </since_tizen>
563 public Vector4 SelectionHighlightColor
567 Vector4 temp = (Vector4)GetValue(SelectionHighlightColorProperty);
568 return new Vector4(OnSelectionHighlightColorChanged, temp.X, temp.Y, temp.Z, temp.W);
572 SetValue(SelectionHighlightColorProperty, value);
573 NotifyPropertyChanged();
578 /// The DecorationBoundingBox property.
581 /// The property cascade chaining set is possible. For example, this (textEditor.DecorationBoundingBox.X = 1;) is possible.
583 /// <since_tizen> 3 </since_tizen>
584 public Rectangle DecorationBoundingBox
588 Rectangle temp = (Rectangle)GetValue(DecorationBoundingBoxProperty);
589 return new Rectangle(OnDecorationBoundingBoxChanged, temp.X, temp.Y, temp.Width, temp.Height);
593 SetValue(DecorationBoundingBoxProperty, value);
594 NotifyPropertyChanged();
599 /// The EnableMarkup property.
601 /// <since_tizen> 3 </since_tizen>
602 public bool EnableMarkup
606 return (bool)GetValue(EnableMarkupProperty);
610 SetValue(EnableMarkupProperty, value);
611 NotifyPropertyChanged();
616 /// The InputColor property.
619 /// The property cascade chaining set is possible. For example, this (textEditor.InputColor.X = 0.1f;) is possible.
621 /// <since_tizen> 3 </since_tizen>
622 public Vector4 InputColor
626 Vector4 temp = (Vector4)GetValue(InputColorProperty);
627 return new Vector4(OnInputColorChanged, temp.X, temp.Y, temp.Z, temp.W);
631 SetValue(InputColorProperty, value);
632 NotifyPropertyChanged();
637 /// The InputFontFamily property.
639 /// <since_tizen> 3 </since_tizen>
640 public string InputFontFamily
644 return (string)GetValue(InputFontFamilyProperty);
648 SetValue(InputFontFamilyProperty, value);
649 NotifyPropertyChanged();
654 /// The InputFontStyle property.
655 /// The inputFontStyle map contains the following keys :<br />
656 /// <list type="table">
657 /// <item><term>width (string)</term><description>The width key defines occupied by each glyph. (values: ultraCondensed, extraCondensed, condensed, semiCondensed, normal, semiExpanded, expanded, extraExpanded, ultraExpanded)</description></item>
658 /// <item><term>weight (string)</term><description>The weight key defines the thickness or darkness of the glyphs. (values: thin, ultraLight, extraLight, light, demiLight, semiLight, book, normal, regular, medium, demiBold, semiBold, bold, ultraBold, extraBold, black, heavy, extraBlack)</description></item>
659 /// <item><term>slant (string)</term><description>The slant key defines whether to use italics. (values: normal, roman, italic, oblique)</description></item>
662 /// <since_tizen> 3 </since_tizen>
663 public PropertyMap InputFontStyle
667 return (PropertyMap)GetValue(InputFontStyleProperty);
671 SetValue(InputFontStyleProperty, value);
672 NotifyPropertyChanged();
677 /// The InputPointSize property.
679 /// <since_tizen> 3 </since_tizen>
680 public float InputPointSize
684 return (float)GetValue(InputPointSizeProperty);
688 SetValue(InputPointSizeProperty, value);
689 NotifyPropertyChanged();
694 /// The LineSpacing property.
696 /// <since_tizen> 3 </since_tizen>
697 public float LineSpacing
701 return (float)GetValue(LineSpacingProperty);
705 SetValue(LineSpacingProperty, value);
706 NotifyPropertyChanged();
711 /// The InputLineSpacing property.
713 /// <since_tizen> 3 </since_tizen>
714 public float InputLineSpacing
718 return (float)GetValue(InputLineSpacingProperty);
722 SetValue(InputLineSpacingProperty, value);
723 NotifyPropertyChanged();
728 /// The Underline property.
729 /// The underline map contains the following keys :<br />
730 /// <list type="table">
731 /// <item><term>enable (bool)</term><description>Whether the underline is enabled (the default value is false)</description></item>
732 /// <item><term>color (Color)</term><description>The color of the underline (If not provided then the color of the text is used)</description></item>
733 /// <item><term>height (float)</term><description>The height in pixels of the underline (the default value is 1.f)</description></item>
736 /// <since_tizen> 3 </since_tizen>
737 public PropertyMap Underline
741 return (PropertyMap)GetValue(UnderlineProperty);
745 SetValue(UnderlineProperty, value);
746 NotifyPropertyChanged();
751 /// The InputUnderline property.
753 /// <since_tizen> 3 </since_tizen>
754 public string InputUnderline
758 return (string)GetValue(InputUnderlineProperty);
762 SetValue(InputUnderlineProperty, value);
763 NotifyPropertyChanged();
768 /// The Shadow property.
769 /// The shadow map contains the following keys :<br />
770 /// <list type="table">
771 /// <item><term>color (Color)</term><description>The color of the shadow (the default color is Color.Black)</description></item>
772 /// <item><term>offset (Vector2)</term><description>The offset in pixels of the shadow (If not provided then the shadow is not enabled)</description></item>
773 /// <item><term>blurRadius (float)</term><description>The radius of the Gaussian blur for the soft shadow (If not provided then the soft shadow is not enabled)</description></item>
776 /// <since_tizen> 3 </since_tizen>
777 public PropertyMap Shadow
781 return (PropertyMap)GetValue(ShadowProperty);
785 SetValue(ShadowProperty, value);
786 NotifyPropertyChanged();
791 /// The InputShadow property.
793 /// <since_tizen> 3 </since_tizen>
794 public string InputShadow
798 return (string)GetValue(InputShadowProperty);
802 SetValue(InputShadowProperty, value);
803 NotifyPropertyChanged();
808 /// The Emboss property.
810 /// <since_tizen> 3 </since_tizen>
815 return (string)GetValue(EmbossProperty);
819 SetValue(EmbossProperty, value);
820 NotifyPropertyChanged();
825 /// The InputEmboss property.
827 /// <since_tizen> 3 </since_tizen>
828 public string InputEmboss
832 return (string)GetValue(InputEmbossProperty);
836 SetValue(InputEmbossProperty, value);
837 NotifyPropertyChanged();
842 /// The Outline property.
843 /// The outline map contains the following keys :<br />
844 /// <list type="table">
845 /// <item><term>color (Color)</term><description>The color of the outline (the default color is Color.White)</description></item>
846 /// <item><term>width (float)</term><description>The width in pixels of the outline (If not provided then the outline is not enabled)</description></item>
849 /// <since_tizen> 3 </since_tizen>
850 public PropertyMap Outline
854 return (PropertyMap)GetValue(OutlineProperty);
858 SetValue(OutlineProperty, value);
859 NotifyPropertyChanged();
864 /// The InputOutline property.
866 /// <since_tizen> 3 </since_tizen>
867 public string InputOutline
871 return (string)GetValue(InputOutlineProperty);
875 SetValue(InputOutlineProperty, value);
876 NotifyPropertyChanged();
881 /// The SmoothScroll property.
883 /// <since_tizen> 3 </since_tizen>
884 public bool SmoothScroll
888 return (bool)GetValue(SmoothScrollProperty);
892 SetValue(SmoothScrollProperty, value);
893 NotifyPropertyChanged();
898 /// The SmoothScrollDuration property.
900 /// <since_tizen> 3 </since_tizen>
901 public float SmoothScrollDuration
905 return (float)GetValue(SmoothScrollDurationProperty);
909 SetValue(SmoothScrollDurationProperty, value);
910 NotifyPropertyChanged();
915 /// The EnableScrollBar property.
917 /// <since_tizen> 3 </since_tizen>
918 public bool EnableScrollBar
922 return (bool)GetValue(EnableScrollBarProperty);
926 SetValue(EnableScrollBarProperty, value);
927 NotifyPropertyChanged();
932 /// The ScrollBarShowDuration property.
934 /// <since_tizen> 3 </since_tizen>
935 public float ScrollBarShowDuration
939 return (float)GetValue(ScrollBarShowDurationProperty);
943 SetValue(ScrollBarShowDurationProperty, value);
944 NotifyPropertyChanged();
949 /// The ScrollBarFadeDuration property.
951 /// <since_tizen> 3 </since_tizen>
952 public float ScrollBarFadeDuration
956 return (float)GetValue(ScrollBarFadeDurationProperty);
960 SetValue(ScrollBarFadeDurationProperty, value);
961 NotifyPropertyChanged();
966 /// The PixelSize property.
968 /// <since_tizen> 3 </since_tizen>
969 public float PixelSize
973 return (float)GetValue(PixelSizeProperty);
977 SetValue(PixelSizeProperty, value);
978 NotifyPropertyChanged();
983 /// The line count of the text.
985 /// <since_tizen> 3 </since_tizen>
991 GetProperty(TextEditor.Property.LineCount).Get(out temp);
997 /// The text to display when the TextEditor is empty and inactive.
999 /// <since_tizen> 3 </since_tizen>
1000 public string PlaceholderText
1004 return (string)GetValue(PlaceholderTextProperty);
1008 SetValue(PlaceholderTextProperty, value);
1009 NotifyPropertyChanged();
1014 /// The Selected Text property (read-only).
1016 [EditorBrowsable(EditorBrowsableState.Never)]
1017 public string SelectedText
1022 GetProperty(TextEditor.Property.SelectedText).Get(out temp);
1028 /// The Placeholder text color.
1031 /// The property cascade chaining set is possible. For example, this (textEditor.PlaceholderTextColor.X = 0.1f;) is possible.
1033 /// <since_tizen> 3 </since_tizen>
1034 public Color PlaceholderTextColor
1038 Color temp = (Color)GetValue(PlaceholderTextColorProperty);
1039 return new Color(OnPlaceholderTextColorChanged, temp.R, temp.G, temp.B, temp.A);
1043 SetValue(PlaceholderTextColorProperty, value);
1044 NotifyPropertyChanged();
1049 /// The EnableSelection property.
1051 /// <since_tizen> 3 </since_tizen>
1052 public bool EnableSelection
1056 return (bool)GetValue(EnableSelectionProperty);
1060 SetValue(EnableSelectionProperty, value);
1061 NotifyPropertyChanged();
1066 /// The start index for selection.
1068 /// <since_tizen> 8 </since_tizen>
1069 /// This will be public opened in tizen_6.0 after ACR done, Before ACR, need to be hidden as inhouse API.
1070 [EditorBrowsable(EditorBrowsableState.Never)]
1071 public int SelectedTextStart
1076 GetProperty(TextEditor.Property.SelectedTextStart).Get(out temp);
1081 SetProperty(TextEditor.Property.SelectedTextStart, new PropertyValue(value));
1082 NotifyPropertyChanged();
1087 /// The end index for selection.
1089 /// <since_tizen> 8 </since_tizen>
1090 /// This will be public opened in tizen_6.0 after ACR done, Before ACR, need to be hidden as inhouse API.
1091 [EditorBrowsable(EditorBrowsableState.Never)]
1092 public int SelectedTextEnd
1097 GetProperty(TextEditor.Property.SelectedTextEnd).Get(out temp);
1102 SetProperty(TextEditor.Property.SelectedTextEnd, new PropertyValue(value));
1103 NotifyPropertyChanged();
1108 /// Enable editing in text control.
1110 /// <since_tizen> 8 </since_tizen>
1111 /// This will be public opened in tizen_6.0 after ACR done, Before ACR, need to be hidden as inhouse API.
1112 [EditorBrowsable(EditorBrowsableState.Never)]
1113 public bool EnableEditing
1118 GetProperty(TextEditor.Property.EnableEditing).Get(out temp);
1123 SetProperty(TextEditor.Property.EnableEditing, new PropertyValue(value));
1124 NotifyPropertyChanged();
1129 /// Specify horizontal scroll position in text control.
1131 [EditorBrowsable(EditorBrowsableState.Never)]
1132 public int HorizontalScrollPosition
1137 using (PropertyValue propertyValue = GetProperty(TextEditor.Property.HorizontalScrollPosition))
1139 propertyValue.Get(out temp);
1145 using (PropertyValue propertyValue = new PropertyValue(value))
1147 SetProperty(TextEditor.Property.HorizontalScrollPosition, propertyValue);
1148 NotifyPropertyChanged();
1154 /// Specify vertical scroll position in text control.
1156 [EditorBrowsable(EditorBrowsableState.Never)]
1157 public int VerticalScrollPosition
1162 using (PropertyValue propertyValue = GetProperty(TextEditor.Property.VerticalScrollPosition))
1164 propertyValue.Get(out temp);
1170 using (PropertyValue propertyValue = new PropertyValue(value))
1172 SetProperty(TextEditor.Property.VerticalScrollPosition, propertyValue);
1173 NotifyPropertyChanged();
1179 /// Specify primary cursor (caret) position in text control.
1181 [EditorBrowsable(EditorBrowsableState.Never)]
1182 public int PrimaryCursorPosition
1187 using (PropertyValue propertyValue = GetProperty(TextEditor.Property.PrimaryCursorPosition))
1189 propertyValue.Get(out temp);
1195 using (PropertyValue propertyValue = new PropertyValue(value))
1197 SetProperty(TextEditor.Property.PrimaryCursorPosition, propertyValue);
1198 NotifyPropertyChanged();
1204 /// The GrabHandleColor property.
1207 /// The property cascade chaining set is possible. For example, this (textEditor.GrabHandleColor.X = 0.1f;) is possible.
1209 [EditorBrowsable(EditorBrowsableState.Never)]
1210 public Color GrabHandleColor
1214 Color temp = (Color)GetValue(GrabHandleColorProperty);
1215 return new Color(OnGrabHandleColorChanged, temp.R, temp.G, temp.B, temp.A);
1219 SetValue(GrabHandleColorProperty, value);
1220 NotifyPropertyChanged();
1225 /// The Placeholder property.
1226 /// The placeholder map contains the following keys :<br />
1227 /// <list type="table">
1228 /// <item><term>text (string)</term><description>The text to display when the TextEditor is empty and inactive</description></item>
1229 /// <item><term>textFocused (string)</term><description>The text to display when the placeholder has focus</description></item>
1230 /// <item><term>color (Color)</term><description>The color of the placeholder text</description></item>
1231 /// <item><term>fontFamily (string)</term><description>The fontFamily of the placeholder text</description></item>
1232 /// <item><term>fontStyle (PropertyMap)</term><description>The fontStyle of the placeholder text</description></item>
1233 /// <item><term>pointSize (float)</term><description>The pointSize of the placeholder text</description></item>
1234 /// <item><term>pixelSize (float)</term><description>The pixelSize of the placeholder text</description></item>
1235 /// <item><term>ellipsis (bool)</term><description>The ellipsis of the placeholder text</description></item>
1239 /// The following example demonstrates how to set the placeholder property.
1241 /// PropertyMap propertyMap = new PropertyMap();
1242 /// propertyMap.Add("text", new PropertyValue("Setting Placeholder Text"));
1243 /// propertyMap.Add("textFocused", new PropertyValue("Setting Placeholder Text Focused"));
1244 /// propertyMap.Add("color", new PropertyValue(Color.Red));
1245 /// propertyMap.Add("fontFamily", new PropertyValue("Arial"));
1246 /// propertyMap.Add("pointSize", new PropertyValue(12.0f));
1248 /// PropertyMap fontStyleMap = new PropertyMap();
1249 /// fontStyleMap.Add("weight", new PropertyValue("bold"));
1250 /// fontStyleMap.Add("width", new PropertyValue("condensed"));
1251 /// fontStyleMap.Add("slant", new PropertyValue("italic"));
1252 /// propertyMap.Add("fontStyle", new PropertyValue(fontStyleMap));
1254 /// TextEditor editor = new TextEditor();
1255 /// editor.Placeholder = propertyMap;
1258 /// <since_tizen> 3 </since_tizen>
1259 public Tizen.NUI.PropertyMap Placeholder
1263 PropertyMap map = (PropertyMap)GetValue(PlaceholderProperty);
1264 PropertyValue value = null;
1267 value = map.Find(0);
1270 value.Get(out string text);
1271 map.Add("text", new PropertyValue(text));
1275 value = map.Find(1);
1278 value.Get(out string textFocused);
1279 map.Add("textFocused", new PropertyValue(textFocused));
1283 value = map.Find(2);
1286 Color color = new Color();
1288 map.Add("color", new PropertyValue(color));
1292 value = map.Find(3);
1295 value.Get(out string fontFamily);
1296 map.Add("fontFamily", new PropertyValue(fontFamily));
1300 value = map.Find(4);
1303 PropertyMap fontStyle = new PropertyMap();
1304 value.Get(fontStyle);
1305 map.Add("fontStyle", new PropertyValue(fontStyle));
1309 value = map.Find(5);
1312 value.Get(out float pointSize);
1313 map.Add("pointSize", new PropertyValue(pointSize));
1317 value = map.Find(6);
1320 value.Get(out float pixelSize);
1321 map.Add("pixelSize", new PropertyValue(pixelSize));
1325 value = map.Find(7);
1328 value.Get(out bool ellipsis);
1329 map.Add("ellipsis", new PropertyValue(ellipsis));
1336 SetValue(PlaceholderProperty, value);
1337 NotifyPropertyChanged();
1342 /// The LineWrapMode property.<br />
1343 /// The line wrap mode when the text lines over the layout width.<br />
1345 /// <since_tizen> 4 </since_tizen>
1346 public LineWrapMode LineWrapMode
1350 return (LineWrapMode)GetValue(LineWrapModeProperty);
1354 SetValue(LineWrapModeProperty, value);
1355 NotifyPropertyChanged();
1360 /// Enables Text selection using Shift key.
1362 /// <since_tizen> 5 </since_tizen>
1363 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
1364 [EditorBrowsable(EditorBrowsableState.Never)]
1365 public bool EnableShiftSelection
1369 return (bool)GetValue(EnableShiftSelectionProperty);
1373 SetValue(EnableShiftSelectionProperty, value);
1374 NotifyPropertyChanged();
1379 /// The text alignment to match the direction of the system language.
1381 /// <since_tizen> 6 </since_tizen>
1382 public bool MatchSystemLanguageDirection
1386 return (bool)GetValue(MatchSystemLanguageDirectionProperty);
1390 SetValue(MatchSystemLanguageDirectionProperty, value);
1391 NotifyPropertyChanged();
1396 /// The MaxLength property.
1398 /// This will be public opened in tizen_6.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1399 [EditorBrowsable(EditorBrowsableState.Never)]
1400 public int MaxLength
1404 return (int)GetValue(MaxLengthProperty);
1408 SetValue(MaxLengthProperty, value);
1409 NotifyPropertyChanged();
1413 /// Only used by the IL of xaml, will never changed to not hidden.
1414 [EditorBrowsable(EditorBrowsableState.Never)]
1415 public override bool IsCreateByXaml
1419 return base.IsCreateByXaml;
1423 base.IsCreateByXaml = value;
1427 this.TextChanged += (obj, e) =>
1429 this.Text = e.TextEditor.Text;
1436 /// The FontSizeScale property. <br />
1437 /// The default value is 1.0. <br />
1438 /// If FontSizeScale.UseSystemSetting, will use the SystemSettings.FontSize internally. <br />
1440 /// <since_tizen> 9 </since_tizen>
1441 public float FontSizeScale
1445 return fontSizeScale;
1449 float newFontSizeScale;
1451 if (fontSizeScale == value) return;
1453 fontSizeScale = value;
1454 if (fontSizeScale == Tizen.NUI.FontSizeScale.UseSystemSetting)
1456 SystemSettingsFontSize systemSettingsFontSize;
1460 systemSettingsFontSize = SystemSettings.FontSize;
1464 Console.WriteLine("{0} Exception caught.", e);
1465 systemSettingsFontSize = SystemSettingsFontSize.Normal;
1467 newFontSizeScale = TextUtils.GetFontSizeScale(systemSettingsFontSize);
1468 addFontSizeChangedCallback();
1472 newFontSizeScale = fontSizeScale;
1473 removeFontSizeChangedCallback();
1476 SetValue(FontSizeScaleProperty, newFontSizeScale);
1477 NotifyPropertyChanged();
1482 /// The InputMethodSettings property.
1485 /// <see cref="InputMethod"/> is a class encapsulating the input method map. Please use the <see cref="InputMethod"/> class for this property.
1488 /// The following example demonstrates how to set the InputMethodSettings property.
1490 /// InputMethod method = new InputMethod();
1491 /// method.PanelLayout = InputMethod.PanelLayoutType.Normal;
1492 /// method.ActionButton = InputMethod.ActionButtonTitleType.Default;
1493 /// method.AutoCapital = InputMethod.AutoCapitalType.Word;
1494 /// method.Variation = 1;
1495 /// textEditor.InputMethodSettings = method.OutputMap;
1498 [EditorBrowsable(EditorBrowsableState.Never)]
1499 public PropertyMap InputMethodSettings
1503 return (PropertyMap)GetValue(InputMethodSettingsProperty);
1507 SetValue(InputMethodSettingsProperty, value);
1508 NotifyPropertyChanged();
1513 /// Scroll the text control by specific amount..
1515 /// <param name="scroll">The amount (in pixels) of scrolling in horizontal & vertical directions.</param>
1516 [EditorBrowsable(EditorBrowsableState.Never)]
1517 public void ScrollBy(Vector2 scroll)
1519 Interop.TextEditor.ScrollBy(SwigCPtr, Vector2.getCPtr(scroll));
1520 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1524 /// Get the InputMethodContext instance.
1526 /// <returns>The InputMethodContext instance.</returns>
1527 /// <since_tizen> 5 </since_tizen>
1528 public InputMethodContext GetInputMethodContext()
1530 if (inputMethodContext == null)
1532 /*Avoid raising InputMethodContext reference count.*/
1533 inputMethodContext = new InputMethodContext(Interop.TextEditor.GetInputMethodContext(SwigCPtr), true);
1534 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1536 return inputMethodContext;
1540 /// Select the whole text.
1542 [EditorBrowsable(EditorBrowsableState.Never)]
1543 public void SelectWholeText()
1545 Interop.TextEditor.SelectWholeText(SwigCPtr);
1546 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1550 /// Clear selection of the text.
1552 [EditorBrowsable(EditorBrowsableState.Never)]
1553 public void SelectNone()
1555 _ = Interop.TextEditor.SelectNone(SwigCPtr);
1556 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1560 /// Enable grab handle property.
1562 [EditorBrowsable(EditorBrowsableState.Never)]
1563 public bool EnableGrabHandle
1567 return (bool)GetValue(EnableGrabHandleProperty);
1571 SetValue(EnableGrabHandleProperty, value);
1572 NotifyPropertyChanged();
1577 /// Enable grab handle popup property.
1579 [EditorBrowsable(EditorBrowsableState.Never)]
1580 public bool EnableGrabHandlePopup
1584 return (bool)GetValue(EnableGrabHandlePopupProperty);
1588 SetValue(EnableGrabHandlePopupProperty, value);
1589 NotifyPropertyChanged();
1593 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TextEditor obj)
1595 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
1598 internal SWIGTYPE_p_Dali__SignalT_void_fDali__Toolkit__TextEditor_Dali__Toolkit__TextEditor__InputStyle__MaskF_t InputStyleChangedSignal()
1600 SWIGTYPE_p_Dali__SignalT_void_fDali__Toolkit__TextEditor_Dali__Toolkit__TextEditor__InputStyle__MaskF_t ret = new SWIGTYPE_p_Dali__SignalT_void_fDali__Toolkit__TextEditor_Dali__Toolkit__TextEditor__InputStyle__MaskF_t(Interop.TextEditor.InputStyleChangedSignal(SwigCPtr));
1601 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1608 /// <since_tizen> 3 </since_tizen>
1609 protected override void Dispose(DisposeTypes type)
1616 if (systemlangTextFlag)
1618 SystemSettings.LocaleLanguageChanged -= SystemSettings_LocaleLanguageChanged;
1621 removeFontSizeChangedCallback();
1623 //Release your own unmanaged resources here.
1624 //You should not access any managed member here except static instance.
1625 //because the execution order of Finalizes is non-deterministic.
1629 if (textEditorTextChangedCallbackDelegate != null)
1631 TextChangedSignal().Disconnect(textEditorTextChangedCallbackDelegate);
1634 if (textEditorMaxLengthReachedCallbackDelegate != null)
1636 this.MaxLengthReachedSignal().Disconnect(textEditorMaxLengthReachedCallbackDelegate);
1643 /// This will not be public opened.
1644 [EditorBrowsable(EditorBrowsableState.Never)]
1645 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1647 // In order to speed up IME hide, temporarily add
1648 GetInputMethodContext()?.DestroyContext();
1649 Interop.TextEditor.DeleteTextEditor(swigCPtr);
1652 private string SetTranslatable(string textEditorSid)
1654 string translatableText = null;
1655 translatableText = NUIApplication.MultilingualResourceManager?.GetString(textEditorSid, new CultureInfo(SystemSettings.LocaleLanguage.Replace("_", "-")));
1656 if (translatableText != null)
1658 if (systemlangTextFlag == false)
1660 SystemSettings.LocaleLanguageChanged += SystemSettings_LocaleLanguageChanged;
1661 systemlangTextFlag = true;
1663 return translatableText;
1667 translatableText = "";
1668 return translatableText;
1672 private void SystemSettings_LocaleLanguageChanged(object sender, LocaleLanguageChangedEventArgs e)
1674 if (textEditorTextSid != null)
1676 Text = NUIApplication.MultilingualResourceManager?.GetString(textEditorTextSid, new CultureInfo(e.Value.Replace("_", "-")));
1678 if (textEditorPlaceHolderTextSid != null)
1680 PlaceholderText = NUIApplication.MultilingualResourceManager?.GetString(textEditorPlaceHolderTextSid, new CultureInfo(e.Value.Replace("_", "-")));
1684 private void SystemSettingsFontSizeChanged(object sender, FontSizeChangedEventArgs e)
1686 float newFontSizeScale = TextUtils.GetFontSizeScale(e.Value);
1687 SetValue(FontSizeScaleProperty, newFontSizeScale);
1688 NotifyPropertyChanged();
1691 private void addFontSizeChangedCallback()
1693 if (hasFontSizeChangedCallback != true)
1697 SystemSettings.FontSizeChanged += SystemSettingsFontSizeChanged;
1698 hasFontSizeChangedCallback = true;
1702 Console.WriteLine("{0} Exception caught.", e);
1703 hasFontSizeChangedCallback = false;
1708 private void removeFontSizeChangedCallback()
1710 if (hasFontSizeChangedCallback == true)
1714 SystemSettings.FontSizeChanged -= SystemSettingsFontSizeChanged;
1715 hasFontSizeChangedCallback = false;
1719 Console.WriteLine("{0} Exception caught.", e);
1720 hasFontSizeChangedCallback = true;
1725 internal new class Property
1727 internal static readonly int TEXT = Interop.TextEditor.TextGet();
1728 internal static readonly int TextColor = Interop.TextEditor.TextColorGet();
1729 internal static readonly int FontFamily = Interop.TextEditor.FontFamilyGet();
1730 internal static readonly int FontStyle = Interop.TextEditor.FontStyleGet();
1731 internal static readonly int PointSize = Interop.TextEditor.PointSizeGet();
1732 internal static readonly int HorizontalAlignment = Interop.TextEditor.HorizontalAlignmentGet();
1733 internal static readonly int ScrollThreshold = Interop.TextEditor.ScrollThresholdGet();
1734 internal static readonly int ScrollSpeed = Interop.TextEditor.ScrollSpeedGet();
1735 internal static readonly int PrimaryCursorColor = Interop.TextEditor.PrimaryCursorColorGet();
1736 internal static readonly int SecondaryCursorColor = Interop.TextEditor.SecondaryCursorColorGet();
1737 internal static readonly int EnableCursorBlink = Interop.TextEditor.EnableCursorBlinkGet();
1738 internal static readonly int CursorBlinkInterval = Interop.TextEditor.CursorBlinkIntervalGet();
1739 internal static readonly int CursorBlinkDuration = Interop.TextEditor.CursorBlinkDurationGet();
1740 internal static readonly int CursorWidth = Interop.TextEditor.CursorWidthGet();
1741 internal static readonly int GrabHandleImage = Interop.TextEditor.GrabHandleImageGet();
1742 internal static readonly int GrabHandlePressedImage = Interop.TextEditor.GrabHandlePressedImageGet();
1743 internal static readonly int SelectionHandleImageLeft = Interop.TextEditor.SelectionHandleImageLeftGet();
1744 internal static readonly int SelectionHandleImageRight = Interop.TextEditor.SelectionHandleImageRightGet();
1745 internal static readonly int SelectionHandlePressedImageLeft = Interop.TextEditor.SelectionHandlePressedImageLeftGet();
1746 internal static readonly int SelectionHandlePressedImageRight = Interop.TextEditor.SelectionHandlePressedImageRightGet();
1747 internal static readonly int SelectionHandleMarkerImageLeft = Interop.TextEditor.SelectionHandleMarkerImageLeftGet();
1748 internal static readonly int SelectionHandleMarkerImageRight = Interop.TextEditor.SelectionHandleMarkerImageRightGet();
1749 internal static readonly int SelectionHighlightColor = Interop.TextEditor.SelectionHighlightColorGet();
1750 internal static readonly int DecorationBoundingBox = Interop.TextEditor.DecorationBoundingBoxGet();
1751 internal static readonly int EnableMarkup = Interop.TextEditor.EnableMarkupGet();
1752 internal static readonly int InputColor = Interop.TextEditor.InputColorGet();
1753 internal static readonly int InputFontFamily = Interop.TextEditor.InputFontFamilyGet();
1754 internal static readonly int InputFontStyle = Interop.TextEditor.InputFontStyleGet();
1755 internal static readonly int InputPointSize = Interop.TextEditor.InputPointSizeGet();
1756 internal static readonly int LineSpacing = Interop.TextEditor.LineSpacingGet();
1757 internal static readonly int InputLineSpacing = Interop.TextEditor.InputLineSpacingGet();
1758 internal static readonly int UNDERLINE = Interop.TextEditor.UnderlineGet();
1759 internal static readonly int InputUnderline = Interop.TextEditor.InputUnderlineGet();
1760 internal static readonly int SHADOW = Interop.TextEditor.ShadowGet();
1761 internal static readonly int InputShadow = Interop.TextEditor.InputShadowGet();
1762 internal static readonly int EMBOSS = Interop.TextEditor.EmbossGet();
1763 internal static readonly int InputEmboss = Interop.TextEditor.InputEmbossGet();
1764 internal static readonly int OUTLINE = Interop.TextEditor.OutlineGet();
1765 internal static readonly int InputOutline = Interop.TextEditor.InputOutlineGet();
1766 internal static readonly int SmoothScroll = Interop.TextEditor.SmoothScrollGet();
1767 internal static readonly int SmoothScrollDuration = Interop.TextEditor.SmoothScrollDurationGet();
1768 internal static readonly int EnableScrollBar = Interop.TextEditor.EnableScrollBarGet();
1769 internal static readonly int ScrollBarShowDuration = Interop.TextEditor.ScrollBarShowDurationGet();
1770 internal static readonly int ScrollBarFadeDuration = Interop.TextEditor.ScrollBarFadeDurationGet();
1771 internal static readonly int PixelSize = Interop.TextEditor.PixelSizeGet();
1772 internal static readonly int LineCount = Interop.TextEditor.LineCountGet();
1773 internal static readonly int EnableSelection = Interop.TextEditor.EnableSelectionGet();
1774 internal static readonly int PLACEHOLDER = Interop.TextEditor.PlaceholderGet();
1775 internal static readonly int LineWrapMode = Interop.TextEditor.LineWrapModeGet();
1776 internal static readonly int PlaceholderText = Interop.TextEditor.PlaceholderTextGet();
1777 internal static readonly int PlaceholderTextColor = Interop.TextEditor.PlaceholderTextColorGet();
1778 internal static readonly int EnableShiftSelection = Interop.TextEditor.EnableShiftSelectionGet();
1779 internal static readonly int MatchSystemLanguageDirection = Interop.TextEditor.MatchSystemLanguageDirectionGet();
1780 internal static readonly int MaxLength = Interop.TextEditor.MaxLengthGet();
1781 internal static readonly int SelectedTextStart = Interop.TextEditor.SelectedTextStartGet();
1782 internal static readonly int SelectedTextEnd = Interop.TextEditor.SelectedTextEndGet();
1783 internal static readonly int EnableEditing = Interop.TextEditor.EnableEditingGet();
1784 internal static readonly int SelectedText = Interop.TextEditor.SelectedTextGet();
1785 internal static readonly int HorizontalScrollPosition = Interop.TextEditor.HorizontalScrollPositionGet();
1786 internal static readonly int VerticalScrollPosition = Interop.TextEditor.VerticalScrollPositionGet();
1787 internal static readonly int PrimaryCursorPosition = Interop.TextEditor.PrimaryCursorPositionGet();
1788 internal static readonly int FontSizeScale = Interop.TextEditor.FontSizeScaleGet();
1789 internal static readonly int GrabHandleColor = Interop.TextEditor.GrabHandleColorGet();
1790 internal static readonly int EnableGrabHandle = Interop.TextEditor.EnableGrabHandleGet();
1791 internal static readonly int EnableGrabHandlePopup = Interop.TextEditor.EnableGrabHandlePopupGet();
1792 internal static readonly int InputMethodSettings = Interop.TextEditor.InputMethodSettingsGet();
1795 internal class InputStyle
1801 FontFamily = 0x0002,
1804 LineSpacing = 0x0010,
1812 private void OnDecorationBoundingBoxChanged(int x, int y, int width, int height)
1814 DecorationBoundingBox = new Rectangle(x, y, width, height);
1816 private void OnInputColorChanged(float x, float y, float z, float w)
1818 InputColor = new Vector4(x, y, z, w);
1820 private void OnPlaceholderTextColorChanged(float r, float g, float b, float a)
1822 PlaceholderTextColor = new Color(r, g, b, a);
1824 private void OnPrimaryCursorColorChanged(float x, float y, float z, float w)
1826 PrimaryCursorColor = new Vector4(x, y, z, w);
1828 private void OnSecondaryCursorColorChanged(float x, float y, float z, float w)
1830 SecondaryCursorColor = new Vector4(x, y, z, w);
1832 private void OnSelectionHighlightColorChanged(float x, float y, float z, float w)
1834 SelectionHighlightColor = new Vector4(x, y, z, w);
1836 private void OnTextColorChanged(float x, float y, float z, float w)
1838 TextColor = new Vector4(x, y, z, w);
1840 private void OnGrabHandleColorChanged(float r, float g, float b, float a)
1842 GrabHandleColor = new Color(r, g, b, a);