public void Activate(OnEditDone doneCallback, string original, ValidateText validateTextCallback = null)
        {
            SetText(original);
            shared.blob.End();  // Start with cursor at end of existing string.

            if (state != States.Active)
            {
                shared.onEditDone           = doneCallback;
                shared.validateTextCallback = validateTextCallback;

                //------------------ Copied from other implementation --------------
                // Do stack handling here.  If we do it in the update object we have no
                // clue which order things get pushed and popped and madness ensues.
                CommandStack.Push(commandMap);

                HelpOverlay.Push(@"TextLineEditor");

                //------------------ Copied from other implementation END --------------

                state = States.Active;

                //shared.blob.s

                updateObj.Activate();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// TextInputDialog Creation helper
        /// </summary>
        /// <returns>the dialog created and configured</returns>
        public static TextInputDialog Create(GUIContent titleContent,
                                             Rect position,
                                             string text                     = "",
                                             string message                  = "",
                                             string inputLabel               = "",
                                             GUIContent validButton          = null,
                                             GUIContent cancelButton         = null,
                                             ValidateText validationDelegate = null)
        {
            var dialog = CreateInstance <TextInputDialog>();

            dialog.titleContent = titleContent;
            dialog.position     = position;
            if (position.width > 0 && position.height > 0)
            {
                dialog.minSize = new Vector2(position.width, position.height);
                dialog.maxSize = dialog.minSize;
            }
            dialog.Text       = text;
            dialog.Message    = message;
            dialog.InputLabel = inputLabel;
            if (validButton != null)
            {
                dialog.ValidationButton = validButton;
            }
            if (cancelButton != null)
            {
                dialog.CancelButton = cancelButton;
            }
            dialog.ValidationDelegate = validationDelegate;
            return(dialog);
        }
 protected virtual void OnValidateText(object sender, ValidateTextEventArgs e) => ValidateText?.Invoke(this, e);