From 350c1e8a6d57338a1f1ecfdd6482134a623cb823 Mon Sep 17 00:00:00 2001 From: Bowon Ryu Date: Wed, 25 Aug 2021 17:18:18 +0900 Subject: [PATCH] [NUI] Add SetHiddenInput, GetHiddenInput to TextField MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Add a HiddenInput struct to pass data of DALi HiddenInputSettings PropertyMap. The HiddenInput struct can be used as an argument to SetHiddenInput and GetHiddenInput methods. // example var hiddenInput = new Tizen.NUI.Text.HiddenInput(); hiddenInput.Mode = HiddenInputModeType.ShowLastCharacter; hiddenInput.SubstituteCharacter = '★'; hiddenInput.SubstituteCount = 0; hiddenInput.ShowLastCharacterDuration = 1000; field.SetHiddenInput(hiddenInput); Signed-off-by: Bowon Ryu --- .../src/public/BaseComponents/TextField.cs | 40 +++++++++++++ .../src/public/BaseComponents/TextUtils.cs | 69 ++++++++++++++++++++++ src/Tizen.NUI/src/public/Common/NUIConstants.cs | 35 +++++++++++ 3 files changed, 144 insertions(+) diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs index 8466caa..524d158 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs @@ -1348,6 +1348,46 @@ namespace Tizen.NUI.BaseComponents } /// + /// Set HiddenInput to TextField.
+ ///
+ /// The HiddenInput + /// + /// SetHiddenInput specifies the requested font style through .
+ ///
+ /// + /// The following example demonstrates how to use the SetHiddenInput method. + /// + /// var hiddenInput = new Tizen.NUI.Text.HiddenInput(); + /// hiddenInput.Mode = HiddenInputModeType.ShowLastCharacter; + /// hiddenInput.SubstituteCharacter = '★'; + /// hiddenInput.SubstituteCount = 0; + /// hiddenInput.ShowLastCharacterDuration = 1000; + /// field.SetHiddenInput(hiddenInput); + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetHiddenInput(HiddenInput hiddenInput) + { + SetProperty(TextField.Property.HiddenInputSettings, new PropertyValue(TextUtils.GetHiddenInputMap(hiddenInput))); + NotifyPropertyChanged(); + } + + /// + /// Get HiddenInput from TextField.
+ ///
+ /// The HiddenInput + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public HiddenInput GetHiddenInput() + { + var map = new PropertyMap(); + GetProperty(TextField.Property.HiddenInputSettings).Get(map); + return TextUtils.GetHiddenInputStruct(map); + } + + /// /// The PixelSize property. /// /// 3 diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextUtils.cs b/src/Tizen.NUI/src/public/BaseComponents/TextUtils.cs index 10e8e38..bed09c3 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextUtils.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextUtils.cs @@ -1682,6 +1682,75 @@ namespace Tizen.NUI.BaseComponents } /// + /// This method converts a HiddenInput struct to a PropertyMap and returns it. + /// The returned map can be used for set HiddenInputSettings PropertyMap in the SetHiddenInput method. + /// The HiddenInput struct value. + /// A PropertyMap for HiddenInput property. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static PropertyMap GetHiddenInputMap(HiddenInput hiddenInput) + { + var map = new PropertyMap(); + + map.Add(0, new PropertyValue((int)hiddenInput.Mode)); + + if (hiddenInput.SubstituteCharacter != null) + map.Add(1, new PropertyValue(Convert.ToInt32(hiddenInput.SubstituteCharacter))); + + if (hiddenInput.SubstituteCount != null) + map.Add(2, new PropertyValue((int)hiddenInput.SubstituteCount)); + + if (hiddenInput.ShowLastCharacterDuration != null) + map.Add(3, new PropertyValue((int)hiddenInput.ShowLastCharacterDuration)); + + return map; + } + + /// + /// This method converts a HiddenInputSettings map to a struct and returns it. + /// The returned struct can be returned to the user as a HiddenInput in the GetHiddenInput method. + /// The HiddenInput PropertyMap. + /// A HiddenInput struct. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static HiddenInput GetHiddenInputStruct(PropertyMap map) + { + PropertyValue value = null; + + var hiddenInput = new HiddenInput(); + + value = map.Find(0); + if (value != null) + { + value.Get(out int mode); + hiddenInput.Mode = (HiddenInputModeType)mode; + } + + value = map.Find(1); + if (value != null) + { + value.Get(out int substituteCharacter); + hiddenInput.SubstituteCharacter = Convert.ToChar(substituteCharacter); + } + + value = map.Find(2); + if (value != null) + { + value.Get(out int substituteCount); + hiddenInput.SubstituteCount = substituteCount; + } + + value = map.Find(3); + if (value != null) + { + value.Get(out int showLastCharacterDuration); + hiddenInput.ShowLastCharacterDuration = showLastCharacterDuration; + } + + return hiddenInput; + } + + /// /// Copy the previously selected text into the clipboard and return the copied value. /// /// The textEditor control from which the text is copied. diff --git a/src/Tizen.NUI/src/public/Common/NUIConstants.cs b/src/Tizen.NUI/src/public/Common/NUIConstants.cs index ed69f6d..95aef4a 100755 --- a/src/Tizen.NUI/src/public/Common/NUIConstants.cs +++ b/src/Tizen.NUI/src/public/Common/NUIConstants.cs @@ -2279,5 +2279,40 @@ namespace Tizen.NUI [EditorBrowsable(EditorBrowsableState.Never)] public bool Ellipsis { get; set; } } + + /// + /// A struct to pass data of HiddenInputSettings PropertyMap.
+ ///
+ /// + /// The HiddenInput struct is used as an argument to SetHiddenInput and GetHiddenInput methods.
+ /// See and .
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)] + public struct HiddenInput + { + /// + /// The mode for input text display.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)] + public HiddenInputModeType Mode { get; set; } + + /// + /// All input characters are substituted by this character (if null, the default value is '*').
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)] + public char? SubstituteCharacter { get; set; } + + /// + /// Length of text to show or hide, available when HideCount/ShowCount mode is used (if null, the default value is 0).
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)] + public int? SubstituteCount { get; set; } + + /// + /// Hide last character after this duration, available when ShowLastCharacter mode (if null, the default value is 1000).
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)] + public int? ShowLastCharacterDuration { get; set; } + } } } -- 2.7.4