Exemplo n.º 1
0
        public void TokenTextFieldDeleteBackward(TokenTextField tokenTextField)
        {
            if (_canNotDeletedToken)
            {
                _canNotDeletedToken = false;
            }
            else
            {
                bool removeTokenButton = false;
                foreach (TokenButton tokenButton in _tokens)
                {
                    if (tokenButton._toggled)
                    {
                        RemoveTokenForTitle(tokenButton);
                        removeTokenButton = true;
                        break;
                    }
                }

                if (!removeTokenButton)
                {
                    // Highlight last token button
                    if (_tokens.Count > 0)
                    {
                        TokenButton tokenButtonHighlight = _tokens[_tokens.Count - 1];
                        if (tokenButtonHighlight != null)
                        {
                            tokenButtonHighlight.SetToggled(true);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        void CommonSetup()
        {
            _tokens = new List <TokenButton>();

            if (Frame.Height < (DEFAULT_HEIGHT + HEIGHT_PADDING * 2))
            {
                CGRect newFrame = Frame;
                newFrame.Height = DEFAULT_HEIGHT + HEIGHT_PADDING * 2;
                Frame           = newFrame;
            }

            CGRect frame = Frame;

            frame.Y      += HEIGHT_PADDING;
            frame.Height -= HEIGHT_PADDING * 2;

            _textField = new TokenTextField(frame);
            _textField.TokenDelegate     = this;
            _textField.BorderStyle       = UITextBorderStyle.None;
            _textField.BackgroundColor   = UIColor.Clear;
            _textField.VerticalAlignment = UIControlContentVerticalAlignment.Center;

            AddSubview(_textField);

            _textField.ShouldReturn += TextFieldShouldReturn;

            _textField.ShouldBeginEditing = (UITextField textField) =>
            {
                _canNotDeletedToken = false;
                return(true);
            };
            _textField.ShouldChangeCharacters = (textField, range, replacementString) =>
            {
                _canNotDeletedToken = true;
                return(true);
            };
        }