Example #1
0
        public static string DrawTextField(
            string uniqueFieldKey,
            string label,
            string currentContent,
            Action repaintCallback,
            Action <string> updateTextCallback,
            bool multiline = false)
        {
            var currentRect = EditorGUILayout.BeginHorizontal();

            GUILayout.Space(EditorGUI.indentLevel * 20);

            var result = SpellCheckCache.QueueChecking(uniqueFieldKey, currentContent, repaintCallback);

            if (result == null)
            {
                if (Buttons.Loading())
                {
                }
            }
            else if (result.Length == 0)
            {
                Buttons.Valid();
            }
            else
            {
                if (Buttons.Warning())
                {
                    var popupContent = new SpellCheckHintsContent(currentContent, result, (newRow) =>
                    {
                        updateTextCallback(newRow);
                        repaintCallback();
                    });
                    PopupWindow.Show(
                        new Rect(currentRect.x + 30, currentRect.y, currentRect.width, currentRect.height),
                        popupContent);
                }
            }
            currentContent =
                multiline ? EditorGUILayout.TextArea(currentContent) :
                string.IsNullOrEmpty(label)
                ? EditorGUILayout.TextField(currentContent) :
                EditorGUILayout.TextField(label, currentContent);
            EditorGUILayout.EndHorizontal();
            return(currentContent);
        }
 private void PrintResultFor(string label, string row, string newRow, ref string result)
 {
     if (row != newRow)
     {
         var info = SpellCheckCache.QueueChecking(label, row, Repaint);
         if (info == null)
         {
             result = "Loading...";
         }
         else if (info.Length == 0)
         {
             result = "No errors";
         }
         else
         {
             result = string.Join(",", info[0].s ?? new string[0]);
         }
     }
     EditorGUILayout.LabelField(label, result);
 }