From: Xianbing Teng Date: Wed, 15 Jan 2020 05:58:41 +0000 (+0800) Subject: [NUI.Components] Remove InputField (#1284) X-Git-Tag: accepted/tizen/5.5/unified/20200116.120633~1^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e60b1dea4eb9abb8f70ad1b8b85c0d096eea781e;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI.Components] Remove InputField (#1284) --- diff --git a/src/Tizen.NUI.Components/Controls/InputField.cs b/src/Tizen.NUI.Components/Controls/InputField.cs deleted file mode 100755 index ece053c..0000000 --- a/src/Tizen.NUI.Components/Controls/InputField.cs +++ /dev/null @@ -1,697 +0,0 @@ -/* - * Copyright(c) 2019 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -using System; -using Tizen.NUI.BaseComponents; -using System.ComponentModel; - -namespace Tizen.NUI.Components -{ - /// - /// InputField is a editable input compoment - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public class InputField : Control - { - // the background image - private ImageView bgImage = null; - // the textField - private TextField textField = null; - // the attributes of the inputField - private InputFieldStyle inputFieldAttrs = null; - // the flag indicate should relayout the textField in base class - private bool relayoutTextField = true; - - static InputField() { } - - /// - /// Initializes a new instance of the InputField class. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public InputField() : base() - { - Initialize(); - } - - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public InputField(string style) : base(style) - { - Initialize(); - } - - /// - /// Initializes a new instance of the InputField class. - /// - /// Create Header by attributes customized by user. - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public InputField(InputFieldStyle attributes) : base(attributes) - { - Initialize(); - } - - /// - /// Gets or sets the property for the enabled state. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public bool StateEnabled - { - get - { - return Sensitive; - } - set - { - Sensitive = value; - } - } - - /// - /// Gets or sets the property for the text content. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public string Text - { - get - { - return textField?.Text; - } - set - { - if (null != textField) textField.Text = value; - } - } - - /// - /// Gets or sets the property for the hint text. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public string HintText - { - get - { - return textField?.PlaceholderText; - } - set - { - if (null != textField) textField.PlaceholderText = value; - } - } - - /// - /// Gets or sets the property for the color of the input text. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public Color TextColor - { - get - { - return textField?.TextColor; - } - set - { - CreateTextFieldAttributes(); - if (null != inputFieldAttrs?.InputBoxAttributes) - { - inputFieldAttrs.InputBoxAttributes.TextColor = value; - if (null != textField) textField.TextColor = value; - } - } - } - - /// - /// Gets or sets text color. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public Color HintTextColor - { - get - { - return textField?.PlaceholderTextColor; - } - set - { - CreateTextFieldAttributes(); - if (null != inputFieldAttrs?.InputBoxAttributes && null != value) - { - Vector4 color = new Vector4(value.R, value.G, value.B, value.A); - inputFieldAttrs.InputBoxAttributes.PlaceholderTextColor = color; - if (null != textField) textField.PlaceholderTextColor = color; - } - } - } - - /// - /// Gets or sets primary cursor color. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public Color PrimaryCursorColor - { - get - { - return textField?.PrimaryCursorColor; - } - set - { - CreateTextFieldAttributes(); - if (null != inputFieldAttrs?.InputBoxAttributes && null != value) - { - Vector4 color = new Vector4(value.R, value.G, value.B, value.A); - inputFieldAttrs.InputBoxAttributes.PrimaryCursorColor = color; - if (null != textField) textField.PrimaryCursorColor = color; - } - } - } - - /// - /// Gets or sets font family of text. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public string FontFamily - { - get - { - return textField?.FontFamily; - } - set - { - CreateTextFieldAttributes(); - if (null != inputFieldAttrs?.InputBoxAttributes) - { - inputFieldAttrs.InputBoxAttributes.FontFamily = value; - if (null != textField) textField.FontFamily = value; - } - } - } - - /// - /// Gets or sets enable cursor blink. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public bool EnableCursorBlink - { - get - { - return textField?.EnableCursorBlink ?? false; - } - set - { - CreateTextFieldAttributes(); - if (null != inputFieldAttrs.InputBoxAttributes) - { - inputFieldAttrs.InputBoxAttributes.EnableCursorBlink = value; - if (null != textField) textField.EnableCursorBlink = value; - } - } - } - - /// - /// Gets or sets enable selection. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public bool EnableSelection - { - get - { - return textField?.EnableSelection ?? false; - } - set - { - CreateTextFieldAttributes(); - if (null != inputFieldAttrs?.InputBoxAttributes) - { - inputFieldAttrs.InputBoxAttributes.EnableSelection = value; - if (null != textField) textField.EnableSelection = value; - } - } - } - - /// - /// Gets or sets cursor width. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public int CursorWidth - { - get - { - return textField?.CursorWidth ?? 0; - } - set - { - CreateTextFieldAttributes(); - if (null != inputFieldAttrs.InputBoxAttributes) - { - inputFieldAttrs.InputBoxAttributes.CursorWidth = value; - if (null != textField) textField.CursorWidth = value; - } - } - } - - /// - /// Gets or sets if enable ellipsis. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public bool EnableEllipsis - { - get - { - return textField?.Ellipsis ?? false; - } - set - { - CreateTextFieldAttributes(); - if (null != inputFieldAttrs.InputBoxAttributes) - { - inputFieldAttrs.InputBoxAttributes.Ellipsis = value; - if (null != textField) textField.Ellipsis = value; - } - } - } - - /// - /// Gets or sets background image's resource url of input field. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public string BackgroundImageURL - { - get - { - return inputFieldAttrs?.BackgroundImageAttributes?.ResourceUrl?.All; - } - set - { - CreateBackgroundAttributes(); - if (null != inputFieldAttrs?.BackgroundImageAttributes) - { - inputFieldAttrs.BackgroundImageAttributes.ResourceUrl = value; - RelayoutRequest(); - } - } - } - - /// - /// Background image's border in Button. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public new Rectangle BackgroundImageBorder - { - get - { - return inputFieldAttrs?.BackgroundImageAttributes?.Border?.All; - } - set - { - CreateBackgroundAttributes(); - if (null != inputFieldAttrs?.BackgroundImageAttributes) - { - inputFieldAttrs.BackgroundImageAttributes.Border = value; - RelayoutRequest(); - } - } - } - - /// - /// Gets and Sets Space. - /// - public int Space - { - get - { - return inputFieldAttrs?.Space ?? 0; - } - set - { - if (null != inputFieldAttrs) - { - inputFieldAttrs.Space = value; - RelayoutRequest(); - } - } - } - - /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public override void ApplyStyle(ViewStyle viewStyle) - { - base.ApplyStyle(viewStyle); - - InputFieldStyle inputFieldStyle = viewStyle as InputFieldStyle; - - if (null != inputFieldStyle.BackgroundImageAttributes) - { - if (null == bgImage) - { - bgImage = new ImageView() - { - WidthResizePolicy = ResizePolicyType.FillToParent, - HeightResizePolicy = ResizePolicyType.FillToParent, - }; - - this.Add(bgImage); - } - bgImage.ApplyStyle(inputFieldStyle.BackgroundImageAttributes); - } - if (null != inputFieldStyle.InputBoxAttributes) - { - if (null == textField) - { - textField = new TextField() - { - WidthResizePolicy = ResizePolicyType.Fixed, - HeightResizePolicy = ResizePolicyType.Fixed, - ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft, - PivotPoint = Tizen.NUI.PivotPoint.CenterLeft, - PositionUsesPivotPoint = true, - }; - this.Add(textField); - textField.FocusGained += OnTextFieldFocusGained; - textField.FocusLost += OnTextFieldFocusLost; - textField.TextChanged += OnTextFieldTextChanged; - textField.KeyEvent += OnTextFieldKeyEvent; - } - textField.ApplyStyle(inputFieldStyle.InputBoxAttributes); - } - } - - /// - /// Get Input Field attribues. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - protected override ViewStyle GetViewStyle() - { - return new InputFieldStyle(); - } - - /// - /// Dispose Input Field and all children on it. - /// - /// Dispose type. - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - protected override void Dispose(DisposeTypes type) - { - if (disposed) - { - return; - } - if (type == DisposeTypes.Explicit) - { - if (bgImage != null) - { - this.Remove(bgImage); - bgImage.Dispose(); - bgImage = null; - } - if (null != textField) - { - textField.FocusGained -= OnTextFieldFocusGained; - textField.FocusLost -= OnTextFieldFocusLost; - textField.TextChanged -= OnTextFieldTextChanged; - textField.KeyEvent -= OnTextFieldKeyEvent; - this.Remove(textField); - textField.Dispose(); - textField = null; - } - } - - base.Dispose(type); - } - - /// - /// Update Input Field by attributes. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - protected override void OnUpdate() - { - RelayoutComponent(); - OnLayoutDirectionChanged(); - } - - /// - /// Theme change callback when theme is changed, this callback will be trigger. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e) - { - InputFieldStyle tempStyle = StyleManager.Instance.GetViewStyle(style) as InputFieldStyle; - if (tempStyle != null) - { - Style.CopyFrom(tempStyle); - RelayoutRequest(); - } - } - - /// - /// Theme change callback when text field focus is gained, this callback will be trigger. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - protected virtual void OnTextFieldFocusGained(object source, EventArgs e) - { - } - - /// - /// Theme change callback when text field is lost, this callback will be trigger. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - protected virtual void OnTextFieldFocusLost(object source, EventArgs e) - { - } - - /// - /// Theme change callback when text field's text is changed, this callback will be trigger. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - protected virtual void OnTextFieldTextChanged(object sender, TextField.TextChangedEventArgs e) - { - } - - /// - /// Theme change callback when text field have a key event, this callback will be trigger. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - protected virtual bool OnTextFieldKeyEvent(object source, KeyEventArgs e) - { - return false; - } - - /// - /// Set the text field 2D size - /// - /// Input Field' width. - /// Input Field' height. - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - protected void SetTextFieldSize2D(int w, int h) - { - if (textField != null) - { - textField.Size2D = new Size2D(w, h); - } - } - - /// - /// Set the text field X pose - /// - /// Input Field' X. - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - protected void SetTextFieldPosX(int x) - { - if (textField != null) - { - textField.PositionX = x; - } - } - - /// - /// Set the text field text color - /// - /// Input Field' color. - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - protected void SetTextFieldTextColor(Color color) - { - if (textField != null) - { - textField.TextColor = color; - } - } - - /// - /// Set the text field relayout flag - /// - /// relayout text field' value. - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - protected void RelayoutTextField(bool value) - { - relayoutTextField = value; - } - - private void Initialize() - { - inputFieldAttrs = Style as InputFieldStyle; - if (null == inputFieldAttrs) - { - throw new Exception("Fail to get the InputField attributes."); - } - - if (null == bgImage) - { - bgImage = new ImageView() - { - WidthResizePolicy = ResizePolicyType.FillToParent, - HeightResizePolicy = ResizePolicyType.FillToParent, - }; - - this.Add(bgImage); - } - if (null == textField) - { - textField = new TextField() - { - WidthResizePolicy = ResizePolicyType.Fixed, - HeightResizePolicy = ResizePolicyType.Fixed, - ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft, - PivotPoint = Tizen.NUI.PivotPoint.CenterLeft, - PositionUsesPivotPoint = true, - }; - this.Add(textField); - textField.FocusGained += OnTextFieldFocusGained; - textField.FocusLost += OnTextFieldFocusLost; - textField.TextChanged += OnTextFieldTextChanged; - textField.KeyEvent += OnTextFieldKeyEvent; - } - } - - private void OnLayoutDirectionChanged() - { - if (inputFieldAttrs == null) return; - if (textField != null) - { - if (LayoutDirection == ViewLayoutDirectionType.LTR) - { - if(inputFieldAttrs.InputBoxAttributes != null) - { - inputFieldAttrs.InputBoxAttributes.HorizontalAlignment = HorizontalAlignment.Begin; - inputFieldAttrs.InputBoxAttributes.ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft; - inputFieldAttrs.InputBoxAttributes.PivotPoint = Tizen.NUI.PivotPoint.CenterLeft; - inputFieldAttrs.InputBoxAttributes.PositionUsesPivotPoint = true; - } - textField.HorizontalAlignment = HorizontalAlignment.Begin; - textField.ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft; - textField.PivotPoint = Tizen.NUI.PivotPoint.CenterLeft; - textField.PositionUsesPivotPoint = true; - } - else //ViewLayoutDirectionType.RTL - { - if (inputFieldAttrs.InputBoxAttributes != null) - { - inputFieldAttrs.InputBoxAttributes.HorizontalAlignment = HorizontalAlignment.End; - inputFieldAttrs.InputBoxAttributes.ParentOrigin = Tizen.NUI.ParentOrigin.CenterRight; - inputFieldAttrs.InputBoxAttributes.PivotPoint = Tizen.NUI.PivotPoint.CenterRight; - } - textField.HorizontalAlignment = HorizontalAlignment.End; - textField.ParentOrigin = Tizen.NUI.ParentOrigin.CenterRight; - textField.PivotPoint = Tizen.NUI.PivotPoint.CenterRight; - textField.PositionUsesPivotPoint = true; - } - } - } - - private void RelayoutComponent() - { - if (!relayoutTextField) - { - return; - } - int space = inputFieldAttrs.Space ?? 0; - - if (textField != null) - { - textField.Size2D = new Size2D(this.Size2D.Width - space * 2, this.Size2D.Height); - textField.PositionX = space; - } - } - - private void CreateBackgroundAttributes() - { - if (null == inputFieldAttrs.BackgroundImageAttributes) - { - inputFieldAttrs.BackgroundImageAttributes = new ImageViewStyle(); - } - } - - private void CreateTextFieldAttributes() - { - if (null == inputFieldAttrs.InputBoxAttributes) - { - inputFieldAttrs.InputBoxAttributes = new TextFieldStyle(); - } - } - } -} diff --git a/src/Tizen.NUI.Components/Style/InputFieldStyle.cs b/src/Tizen.NUI.Components/Style/InputFieldStyle.cs deleted file mode 100755 index efb00bd..0000000 --- a/src/Tizen.NUI.Components/Style/InputFieldStyle.cs +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright(c) 2019 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -using System.ComponentModel; -using Tizen.NUI.BaseComponents; -using Tizen.NUI.Binding; - -namespace Tizen.NUI.Components -{ - /// - /// InputFieldAttributes is a class which saves InputField's ux data. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public class InputFieldStyle : ControlStyle - { - static InputFieldStyle() { } - - /// - /// Creates a new instance of a InputFieldAttributes. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public InputFieldStyle() : base() - { - BackgroundImageAttributes = new ImageViewStyle(); - InputBoxAttributes = new TextFieldStyle(); - } - - /// - /// Creates a new instance of a InputFieldStyle with Style. - /// - /// Create InputFieldStyle by Style customized by user. - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public InputFieldStyle(InputFieldStyle attrs) : base(attrs) - { - if (null == attrs) - { - return; - } - - BackgroundImageAttributes = new ImageViewStyle(); - InputBoxAttributes = new TextFieldStyle(); - - if (null != attrs.BackgroundImageAttributes) - { - BackgroundImageAttributes.CopyFrom(attrs.BackgroundImageAttributes); - } - if (null != attrs.InputBoxAttributes) - { - InputBoxAttributes.CopyFrom(attrs.InputBoxAttributes); - } - if (null != attrs.Space) - { - Space = attrs.Space; - } - } - - /// - /// Gets or sets background image attributes of input field. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public ImageViewStyle BackgroundImageAttributes { get; set; } - - /// - /// Gets or sets input box attributes of input field. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public TextFieldStyle InputBoxAttributes { get; set; } - - /// - /// Gets or sets space. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public int? Space { get; set; } - - /// - /// Attributes's clone function. - /// - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - public override void CopyFrom(BindableObject bindableObject) - { - InputFieldStyle inputFieldAttributes = bindableObject as InputFieldStyle; - - if (null != inputFieldAttributes) - { - Space = inputFieldAttributes.Space; - - if (null != inputFieldAttributes.BackgroundImageAttributes) - { - BackgroundImageAttributes.CopyFrom(inputFieldAttributes.BackgroundImageAttributes); - } - - if (null != inputFieldAttributes.InputBoxAttributes) - { - InputBoxAttributes.CopyFrom(inputFieldAttributes.InputBoxAttributes); - } - } - } - } -} diff --git a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/InputFieldSample.cs b/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/InputFieldSample.cs deleted file mode 100755 index c544160..0000000 --- a/test/Tizen.NUI.Samples/Tizen.NUI.Samples/Samples/InputFieldSample.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System; -using System.Collections.Generic; -using Tizen.NUI.BaseComponents; -using Tizen.NUI.Components; - -namespace Tizen.NUI.Samples -{ - public class InputFieldSample : IExample - { - private TextLabel guideText; - private View rootView; - InputField inputField; - InputFieldStyle inputFieldAttrs; - - public void Activate() - { - Window window = Window.Instance; - - rootView = new View() - { - WidthResizePolicy = ResizePolicyType.FillToParent, - HeightResizePolicy = ResizePolicyType.FillToParent, - BackgroundColor = new Color(0.8f, 0.8f, 0.8f, 0.8f), - Focusable = true - }; - window.Add(rootView); - rootView.TouchEvent += OnRootViewTouchEvent; - CreateInputField(); - CreateGuideText(); - } - - private void CreateGuideText() - { - guideText = new TextLabel(); - guideText.Size2D = new Size2D(1600, 150); - guideText.Position2D = new Position2D(30, 30); - guideText.TextColor = Color.Blue; - guideText.BackgroundColor = Color.White; - guideText.PointSize = 15; - guideText.MultiLine = true; - guideText.Focusable = true; - rootView.Add(guideText); - guideText.Text = - "Tips: \n" + - "This InputField is created with attibutes; \n" + - "User can input text after press on it; \n" + - "User can exit the sample by press \"Esc\" key after touch on any area except the InputField."; - } - - private void CreateInputField() - { - inputFieldAttrs = new InputFieldStyle(); - inputFieldAttrs.Space = 24; - inputFieldAttrs.BackgroundImageAttributes = new ImageViewStyle - { - ResourceUrl = new Selector { All = CommonResource.GetFHResourcePath() + "1. Action bar/search_bg.png" }, - Border = new Selector { All = new Rectangle(45, 45, 0, 0) } - }; - - inputFieldAttrs.InputBoxAttributes = new TextFieldStyle - { - TextColor = new Selector - { - Normal = new Color(0, 0, 0, 1), - Pressed = new Color(0, 0, 0, 1), - Disabled = new Color(0, 0, 0, 0.4f) - }, - PlaceholderTextColor = new Selector - { - All = new Color(0, 0, 0, 0.4f) - }, - HorizontalAlignment = HorizontalAlignment.Begin, - VerticalAlignment = VerticalAlignment.Center, - FontFamily = "SamsungOne 500", - PointSize = new Selector - { - All = 38 - }, - CursorWidth = 2, - }; - - inputField = new InputField(inputFieldAttrs); - inputField.Size2D = new Size2D(1600, 95); - inputField.Position2D = new Position2D(100, 300); - //inputField.Focusable = true; - rootView.Add(inputField); - inputField.FocusGained += onFocusGained; - inputField.FocusLost += onFocusLost; - //inputField.TouchEvent += onTouchEvent; - inputField.HintText = "Please input key word..."; - } - - private bool OnRootViewTouchEvent(object sender, View.TouchEventArgs e) - { - FocusManager.Instance.SetCurrentFocusView(rootView); - return false; - } - - private void onFocusLost(object sender, EventArgs e) - { - - } - - private void onFocusGained(object sender, EventArgs e) - { - - } - - //private bool onTouchEvent(object sender, View.TouchEventArgs e) - //{ - // return false; - //} - - public void Deactivate() - { - if (inputField != null) - { - inputField.FocusGained -= onFocusGained; - inputField.FocusLost -= onFocusLost; - //inputField.TouchEvent -= onTouchEvent; - rootView.Remove(inputField); - inputField.Dispose(); - inputField = null; - } - if (rootView != null) - { - rootView.TouchEvent -= OnRootViewTouchEvent; - Window.Instance.Remove(rootView); - rootView.Dispose(); - } - } - } -}