Example #1
0
 void UndoRedoPerformed()
 {
     m_TitleField.value    = m_Title.text;
     m_ContentsField.value = m_Contents.text;
     m_TitleField.Blur();
     m_ContentsField.Blur();
 }
Example #2
0
        private void OnKeyPressed(KeyDownEvent e)
        {
            switch (e.keyCode)
            {
            case KeyCode.Escape:
                m_EditTitleCancelled = true;
                m_TitleEditor.Blur();
                break;

            case KeyCode.Return:
                m_TitleEditor.Blur();
                break;

            default:
                break;
            }
        }
Example #3
0
        void OnPathTextFieldKeyPressed(KeyDownEvent evt)
        {
            switch (evt.keyCode)
            {
            case KeyCode.Escape:
                m_EditPathCancelled = true;
                m_PathLabelTextField.Blur();
                break;

            case KeyCode.Return:
            case KeyCode.KeypadEnter:
                m_PathLabelTextField.Blur();
                break;

            default:
                break;
            }
        }
Example #4
0
        private void OnTextFieldKeyPressed(KeyDownEvent e)
        {
            switch (e.keyCode)
            {
            case KeyCode.Escape:
                m_EditTitleCancelled = true;
                m_TextField.Blur();
                break;

            case KeyCode.Return:
            case KeyCode.KeypadEnter:
                m_TextField.Blur();
                break;

            default:
                break;
            }
        }
        void CreateNewSelector(StyleSheet styleSheet)
        {
            var newValue = m_NewSelectorTextField.text;

            if (newValue == BuilderConstants.ExplorerInExplorerNewClassSelectorInfoMessage)
            {
                return;
            }

            if (styleSheet == null)
            {
                if (BuilderStyleSheetsUtilities.CreateNewUSSAsset(m_PaneWindow))
                {
                    styleSheet = m_PaneWindow.document.firstStyleSheet;

                    // The EditorWindow will no longer have Focus after we show the
                    // Save Dialog so even though the New Selector field will appear
                    // focused, typing won't do anything. As such, it's better, in
                    // this one case to remove focus from this field so users know
                    // to re-focus it themselves before they can add more selectors.
                    m_NewSelectorTextField.value = string.Empty;
                    m_NewSelectorTextField.Blur();
                }
                else
                {
                    return;
                }
            }
            else
            {
                m_ShouldRefocusSelectorFieldOnBlur = true;
            }

            var newSelectorStr = newValue;

            if (newSelectorStr.StartsWith(BuilderConstants.UssSelectorClassNameSymbol))
            {
                newSelectorStr = BuilderConstants.UssSelectorClassNameSymbol + newSelectorStr.TrimStart(BuilderConstants.UssSelectorClassNameSymbol[0]);
            }

            if (string.IsNullOrEmpty(newSelectorStr))
            {
                return;
            }

            if (newSelectorStr.Length == 1 && (
                    newSelectorStr.StartsWith(BuilderConstants.UssSelectorClassNameSymbol) ||
                    newSelectorStr.StartsWith("-") ||
                    newSelectorStr.StartsWith("_")))
            {
                return;
            }

            if (!BuilderNameUtilities.styleSelectorRegex.IsMatch(newSelectorStr))
            {
                Builder.ShowWarning(BuilderConstants.StyleSelectorValidationSpacialCharacters);
                m_NewSelectorTextField.schedule.Execute(() =>
                {
                    m_NewSelectorTextField.SetValueWithoutNotify(newValue);
                    m_NewSelectorTextField.SelectAll();
                });
                return;
            }

            var selectorContainerElement = m_Viewport.styleSelectorElementContainer;
            var newComplexSelector       = BuilderSharedStyles.CreateNewSelector(selectorContainerElement, styleSheet, newSelectorStr);

            m_Selection.NotifyOfHierarchyChange();
            m_Selection.NotifyOfStylingChange();

            // Try to selected newly created selector.
            var newSelectorElement =
                m_Viewport.styleSelectorElementContainer.FindElement(
                    (e) => e.GetStyleComplexSelector() == newComplexSelector);

            if (newSelectorElement != null)
            {
                m_Selection.Select(null, newSelectorElement);
            }
        }