private void Init(EditorWindow anchorWindow) { m_AnchorWindow = anchorWindow; packageNameField.RegisterCallback <ChangeEvent <string> >(OnTextFieldChange); packageNameField.RegisterCallback <KeyDownEvent>(OnKeyDownShortcut); packageVersionField.RegisterCallback <KeyDownEvent>(OnKeyDownShortcut); m_PackageNamePlaceholder = new TextFieldPlaceholder(packageNameField, L10n.Tr("Name")); m_PackageVersionPlaceholder = new TextFieldPlaceholder(packageVersionField, L10n.Tr("Version (optional)")); submitButton.clickable.clicked += SubmitClicked; }
private void Init(EditorWindow anchorWindow, InputDropdownArgs args) { m_AnchorWindow = anchorWindow; m_WindowSize = args.windowSize ?? k_DefaultWindowSize; inputTextField.value = args.defaultValue ?? string.Empty; inputTextField.RegisterCallback <ChangeEvent <string> >(OnTextFieldChange); inputTextField.RegisterCallback <KeyDownEvent>(OnKeyDownShortcut); m_InputPlaceholder = new TextFieldPlaceholder(inputTextField); m_InputPlaceholder.text = args.placeholderText ?? string.Empty; mainTitle.text = args.title ?? string.Empty; UIUtils.SetElementDisplay(mainTitle, !string.IsNullOrEmpty(mainTitle.text)); var showIcon = false; if (!string.IsNullOrEmpty(args.iconUssClass)) { showIcon = true; icon.AddToClassList(args.iconUssClass); } else if (args.icon != null) { showIcon = true; icon.style.backgroundImage = new StyleBackground((Background)args.icon); } UIUtils.SetElementDisplay(icon, showIcon); submitButton.clickable.clicked += SubmitClicked; submitButton.SetEnabled(!string.IsNullOrWhiteSpace(inputTextField.value)); submitButton.text = !string.IsNullOrEmpty(args.submitButtonText) ? args.submitButtonText : k_DefaultSubmitButtonText; if (args.onInputSubmitted != null) { submitClicked = args.onInputSubmitted; } }