Ejemplo n.º 1
0
        private UITextField CreateMiniTextField(string localeId, OnTextSubmitted onValueChanged)
        {
            UITextField ddObj = UIHelperExtension.AddTextfield(MainPanel, localeId, "", out UILabel label, out UIPanel container);

            container.autoFitChildrenHorizontally = false;
            container.autoLayoutDirection         = LayoutDirection.Horizontal;
            container.autoLayout = true;
            container.autoFitChildrenHorizontally = true;
            container.autoFitChildrenVertically   = true;

            ddObj.isLocalized         = false;
            ddObj.autoSize            = false;
            ddObj.eventTextSubmitted += (x, y) => onValueChanged(y);
            ddObj.name      = localeId;
            ddObj.size      = new Vector3(240, 22);
            ddObj.textScale = 1;


            KlyteMonoUtils.LimitWidthAndBox(label, 130);
            label.textScale         = 1;
            label.padding.top       = 4;
            label.position          = Vector3.zero;
            label.isLocalized       = true;
            label.localeID          = localeId;
            label.verticalAlignment = UIVerticalAlignment.Middle;
            label.textAlignment     = UIHorizontalAlignment.Left;

            return(ddObj);
        }
Ejemplo n.º 2
0
        public UITextField AddTextField(string label,
                                        string value,
                                        OnTextChanged textChangedEvent,
                                        OnTextSubmitted textSubmittedEvent)
        {
            label.ShouldNotBeNullOrEmpty("label");

            return((UITextField)UiHelperBase.AddTextfield(label, value, textChangedEvent, textSubmittedEvent));
        }
        /// <summary>
        /// Fire the text entered event for objects listening to keyboard.
        /// Immediately closes keyboard.
        /// </summary>
        public void Enter()
        {
            if (SubmitOnEnter)
            {
                // Send text entered event and close the keyboard
                OnTextSubmitted?.Invoke(this, EventArgs.Empty);

                Close();
            }
            else
            {
                string enterString = "\n";

                m_CaretPosition = InputField.caretPosition;

                InputField.text  = InputField.text.Insert(m_CaretPosition, enterString);
                m_CaretPosition += enterString.Length;

                UpdateCaretPosition(m_CaretPosition);
            }
        }
        public static UITextField createTextField(UIHelperBase helper, string defaultContent, OnTextChanged onTextChanged, OnTextSubmitted onTextSubmitted)
        {
            var textfield = helper.AddTextfield("..", defaultContent, onTextChanged, onTextSubmitted) as UITextField;
            var parent    = textfield.parent;

            parent.RemoveUIComponent(textfield);
            var label = parent.Find <UILabel>("Label");

            parent.RemoveUIComponent(label);
            UnityEngine.Object.Destroy(label);
            parent.parent.RemoveUIComponent(parent);
            return(textfield);
        }
Ejemplo n.º 5
0
 public object AddTextfield(string text, string defaultContent, OnTextChanged eventChangedCallback, OnTextSubmitted eventSubmittedCallback = null)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 6
0
 public UITextField AddTextField(string name, OnTextChanged eventCallback, string defaultValue = "", OnTextSubmitted eventSubmit = null)
 {
     return((UITextField)AddTextfield(name, defaultValue, eventCallback, eventSubmit));
 }
Ejemplo n.º 7
0
 public object AddTextfield(string text, string defaultContent, OnTextChanged eventChangedCallback, OnTextSubmitted eventSubmittedCallback)
 {
     if ((eventChangedCallback != null || eventSubmittedCallback != null) && !string.IsNullOrEmpty(text))
     {
         UIPanel uIPanel = this.m_Root.AttachUIComponent(UITemplateManager.GetAsGameObject(kTextfieldTemplate)) as UIPanel;
         uIPanel.Find <UILabel>("Label").text = text;
         UITextField uITextField = uIPanel.Find <UITextField>("Text Field");
         uITextField.text              = defaultContent;
         uITextField.eventTextChanged += delegate(UIComponent c, string sel)
         {
             eventChangedCallback?.Invoke(sel);
         };
         uITextField.eventTextSubmitted += delegate(UIComponent c, string sel)
         {
             eventSubmittedCallback?.Invoke(sel);
         };
         return(uITextField);
     }
     DebugOutputPanel.AddMessage(PluginManager.MessageType.Warning, "Cannot create dropdown with no name or no event");
     return(null);
 }
Ejemplo n.º 8
0
        public object AddTextfield(string text, string defaultContent, OnTextChanged eventChangedCallback, OnTextSubmitted eventSubmittedCallback)
        {
            bool   flag = eventChangedCallback != null && !string.IsNullOrEmpty(text);
            object result;

            if (flag)
            {
                UIPanel uIPanel = this.m_Root.AttachUIComponent(UITemplateManager.GetAsGameObject(UIHelperExtension.kTextfieldTemplate)) as UIPanel;
                uIPanel.Find <UILabel>("Label").text = text;
                UITextField uITextField = uIPanel.Find <UITextField>("Text Field");
                uITextField.text              = defaultContent;
                uITextField.eventTextChanged += delegate(UIComponent c, string sel)
                {
                    eventChangedCallback(sel);
                };
                uITextField.eventTextSubmitted += delegate(UIComponent c, string sel)
                {
                    bool flag2 = eventSubmittedCallback != null;
                    if (flag2)
                    {
                        eventSubmittedCallback(sel);
                    }
                };
                result = uITextField;
            }
            else
            {
                DebugOutputPanel.AddMessage(PluginManager.MessageType.Warning, "Cannot create dropdown with no name or no event");
                result = null;
            }
            return(result);
        }