/// <inheritdoc />
        public override InspectableField FindPath(string path)
        {
            string subPath = GetSubPath(path, depth + 1);

            if (string.IsNullOrEmpty(subPath))
            {
                return(null);
            }

            int lastLeftIdx  = subPath.LastIndexOf('[');
            int lastRightIdx = subPath.LastIndexOf(']', lastLeftIdx);

            if (lastLeftIdx == -1 || lastRightIdx == -1)
            {
                return(null);
            }

            int count = lastRightIdx - 1 - lastLeftIdx;

            if (count <= 0)
            {
                return(null);
            }

            string arrayIdxStr = subPath.Substring(lastLeftIdx, count);

            if (!int.TryParse(arrayIdxStr, out int idx))
            {
                return(null);
            }

            if (idx >= listGUIField.NumRows)
            {
                return(null);
            }

            InspectableListGUIRow row   = listGUIField.GetRow(idx);
            InspectableField      field = row?.Field;

            if (field != null)
            {
                if (field.Path == path)
                {
                    return(field);
                }

                return(field.FindPath(path));
            }

            return(null);
        }
Esempio n. 2
0
        /// <inheritdoc />
        public override InspectableField FindPath(string path)
        {
            string subPath = GetSubPath(path, depth + 1);

            if (string.IsNullOrEmpty(subPath))
            {
                return(null);
            }

            int  lastLeftIdx  = subPath.LastIndexOf("Key[");
            int  lastRightIdx = -1;
            bool isKey;

            if (lastLeftIdx != -1)
            {
                lastRightIdx = subPath.LastIndexOf(']', lastLeftIdx);
                isKey        = true;
            }
            else
            {
                lastLeftIdx  = subPath.LastIndexOf("Value[");
                lastRightIdx = subPath.LastIndexOf(']', lastLeftIdx);

                isKey = false;
            }

            if (lastLeftIdx == -1 || lastRightIdx == -1)
            {
                return(null);
            }

            int count = lastRightIdx - 1 - lastLeftIdx;

            if (count <= 0)
            {
                return(null);
            }

            string arrayIdxStr = subPath.Substring(lastLeftIdx, count);

            if (!int.TryParse(arrayIdxStr, out int idx))
            {
                return(null);
            }
            ;

            if (idx >= dictionaryGUIField.NumRows)
            {
                return(null);
            }

            InspectableDictionaryGUIRow row   = dictionaryGUIField.GetRow(idx);
            InspectableField            field = null;

            if (isKey)
            {
                field = row?.FieldKey;
            }
            else
            {
                field = row?.FieldValue;
            }

            if (field != null)
            {
                if (field.Path == path)
                {
                    return(field);
                }

                return(field.FindPath(path));
            }

            return(null);
        }
Esempio n. 3
0
        /// <summary>
        /// Changes keyboard focus to the provided field.
        /// </summary>
        /// <param name="path">Path to the field on the object being inspected.</param>
        public void FocusOnField(string path)
        {
            InspectableField field = InspectableField.FindPath(path, 0, Fields);

            field?.SetHasFocus();
        }