コード例 #1
0
        public override void TextDidChange(IUITextInput textInput)
        {
            // The app has just changed the document's contents, the document context has been updated.
            UIColor textColor = null;

            try
            {
                if (TextDocumentProxy.KeyboardAppearance == UIKeyboardAppearance.Dark)
                {
                    textColor = UIColor.White;
                }
                else
                {
                    textColor = UIColor.Black;
                }

                _nextKeyboardButton.SetTitleColor(textColor, UIControlState.Normal);
                _tokenButton.SetTitleColor(textColor, UIControlState.Normal);
                _debugButton.SetTitleColor(textColor, UIControlState.Normal);

                _returnButton.SetTitle(TextDocumentProxy.ReturnKeyType.ToString(), UIControlState.Normal);
                _returnButton.SizeToFit();
                _returnButton.TranslatesAutoresizingMaskIntoConstraints = false;
            }
            catch (Exception e)
            {
                Debug(e);
            }
        }
コード例 #2
0
 public static void ApplyKeyboard(this IUITextInput textInput, Keyboard keyboard)
 {
     if (textInput is IUITextInputTraits traits)
     {
         ApplyKeyboard(traits, keyboard);
     }
 }
コード例 #3
0
ファイル: TextInputExtensions.cs プロジェクト: Glepooek/maui
        internal static int GetCursorPosition(this IUITextInput platformView, int cursorOffset = 0)
        {
            var zeroPosition          = platformView.GetPosition(platformView.BeginningOfDocument, 0);
            var currentCursorPosition = platformView.SelectedTextRange?.Start ?? zeroPosition;
            var newCursorPosition     = cursorOffset + (int)platformView.GetOffsetFromPosition(platformView.BeginningOfDocument, currentCursorPosition);

            return(Math.Max(0, newCursorPosition));
        }
コード例 #4
0
        public override void TextDidChange(IUITextInput textInput)
        {
            // The app has just changed the document's contents, the document context has been updated.
            var     isDark    = TextDocumentProxy.KeyboardAppearance == UIKeyboardAppearance.Dark;
            UIColor textColor = isDark ? UIColor.White : UIColor.Black;

            nextKeyboardButton.SetTitleColor(textColor, UIControlState.Normal);
        }
コード例 #5
0
		public override void TextDidChange (IUITextInput textInput)
		{
			// The app has just changed the document's contents, the document context has been updated.
			var isDark = TextDocumentProxy.KeyboardAppearance == UIKeyboardAppearance.Dark;
			UIColor textColor = isDark ? UIColor.White : UIColor.Black;

			nextKeyboardButton.SetTitleColor (textColor, UIControlState.Normal);
		}
コード例 #6
0
        public void TextDidChange(IUITextInput textField)
        {
            var field = textField as UITextField;

            if (field != null)
            {
                listener.EditingEnded(field);
            }
        }
コード例 #7
0
        public void SelectionDidChange(IUITextInput uiTextInput)
        {
            var field = uiTextInput as UITextField;

            if (field != null)
            {
                listener.ShouldEndEditing(field);
            }
        }
コード例 #8
0
        public void SelectionWillChange(IUITextInput uiTextInput)
        {
            var field = uiTextInput as UITextField;

            if (field != null)
            {
                field.ShouldBeginEditing(field);
            }
        }
コード例 #9
0
ファイル: TextInputExtensions.cs プロジェクト: Glepooek/maui
        internal static int GetSelectedTextLength(this IUITextInput platformView)
        {
            var selectedTextRange = platformView.SelectedTextRange;

            if (selectedTextRange == null)
            {
                return(0);
            }

            return((int)platformView.GetOffsetFromPosition(selectedTextRange.Start, selectedTextRange.End));
        }
コード例 #10
0
ファイル: Extensions.cs プロジェクト: fortefour/xamarin-forms
        public static void ApplyKeyboard(this IUITextInput textInput, Keyboard keyboard)
        {
            textInput.AutocapitalizationType = UITextAutocapitalizationType.None;
            textInput.AutocorrectionType     = UITextAutocorrectionType.No;
            textInput.SpellCheckingType      = UITextSpellCheckingType.No;

            if (keyboard == Keyboard.Default)
            {
                textInput.AutocapitalizationType = UITextAutocapitalizationType.Sentences;
                textInput.AutocorrectionType     = UITextAutocorrectionType.Default;
                textInput.SpellCheckingType      = UITextSpellCheckingType.Default;
                textInput.KeyboardType           = UIKeyboardType.Default;
            }
            else if (keyboard == Keyboard.Chat)
            {
                textInput.AutocapitalizationType = UITextAutocapitalizationType.Sentences;
                textInput.AutocorrectionType     = UITextAutocorrectionType.Yes;
            }
            else if (keyboard == Keyboard.Email)
            {
                textInput.KeyboardType = UIKeyboardType.EmailAddress;
            }
            else if (keyboard == Keyboard.Numeric)
            {
                textInput.KeyboardType = UIKeyboardType.DecimalPad;
            }
            else if (keyboard == Keyboard.Telephone)
            {
                textInput.KeyboardType = UIKeyboardType.PhonePad;
            }
            else if (keyboard == Keyboard.Text)
            {
                textInput.AutocapitalizationType = UITextAutocapitalizationType.Sentences;
                textInput.AutocorrectionType     = UITextAutocorrectionType.Yes;
                textInput.SpellCheckingType      = UITextSpellCheckingType.Yes;
            }
            else if (keyboard == Keyboard.Url)
            {
                textInput.KeyboardType = UIKeyboardType.Url;
            }
            else if (keyboard is CustomKeyboard)
            {
                var custom = (CustomKeyboard)keyboard;
                var capitalizedSentenceEnabled = (custom.Flags & KeyboardFlags.CapitalizeSentence) == KeyboardFlags.CapitalizeSentence;
                var spellcheckEnabled          = (custom.Flags & KeyboardFlags.Spellcheck) == KeyboardFlags.Spellcheck;
                var suggestionsEnabled         = (custom.Flags & KeyboardFlags.Suggestions) == KeyboardFlags.Suggestions;

                textInput.AutocapitalizationType = capitalizedSentenceEnabled ? UITextAutocapitalizationType.Sentences : UITextAutocapitalizationType.None;
                textInput.AutocorrectionType     = suggestionsEnabled ? UITextAutocorrectionType.Yes : UITextAutocorrectionType.No;
                textInput.SpellCheckingType      = spellcheckEnabled ? UITextSpellCheckingType.Yes : UITextSpellCheckingType.No;
            }
        }
コード例 #11
0
        public void TextWillChange(IUITextInput textField)
        {
            var field = textField as UITextField;

            if (field != null)
            {
                if (AutoCompleteOnFocus && string.IsNullOrEmpty(textField.ToString()))
                {
                    ShouldChangeCharacters(field, new NSRange(0, 0), string.Empty);
                }
                listener.EditingStarted(field);
            }
        }
コード例 #12
0
        public static UITextRange GetTextRange(this IUITextInput textInput, int start, int end)
        {
            if (textInput?.BeginningOfDocument == null)
            {
                return(null);
            }

            var from = textInput.GetPosition(textInput.BeginningOfDocument, start);
            var to   = textInput.GetPosition(textInput.BeginningOfDocument, end);

            if (from == null || to == null)
            {
                return(null);
            }

            return(textInput.GetTextRange(from, to));
        }
コード例 #13
0
        public override void TextDidChange(IUITextInput textInput)
        {
            // The app has just changed the document's contents, the document context has been updated.
            UIColor textColor = null;

            if (TextDocumentProxy.KeyboardAppearance == UIKeyboardAppearance.Dark)
            {
                textColor = UIColor.White;
            }
            else
            {
                textColor = UIColor.Black;
            }

            cameraButton.SetTitleColor(textColor, UIControlState.Normal);
            galleryButton.SetTitleColor(textColor, UIControlState.Normal);
        }
コード例 #14
0
ファイル: TextInputExtensions.cs プロジェクト: Glepooek/maui
        internal static void SetTextRange(this IUITextInput platformView, int start, int selectedTextLength)
        {
            int end = start + selectedTextLength;

            // Let's be sure we have positive positions
            start = Math.Max(start, 0);
            end   = Math.Max(end, 0);

            // Switch start and end positions if necessary
            start = Math.Min(start, end);
            end   = Math.Max(start, end);

            var startPosition = platformView.GetPosition(platformView.BeginningOfDocument, start);
            var endPosition   = platformView.GetPosition(platformView.BeginningOfDocument, end);

            platformView.SelectedTextRange = platformView.GetTextRange(startPosition, endPosition);
        }
コード例 #15
0
 public DetailImageCell(IntPtr handle) : base(handle)
 {
     _text = new VirtualTextInput(this);
 }
コード例 #16
0
ファイル: Extensions.cs プロジェクト: tibotvr/Xamarin.Forms
        public static void ApplyKeyboard(this IUITextInput textInput, Keyboard keyboard)
        {
            textInput.AutocapitalizationType = UITextAutocapitalizationType.None;
            textInput.AutocorrectionType     = UITextAutocorrectionType.No;
            textInput.SpellCheckingType      = UITextSpellCheckingType.No;
            textInput.KeyboardType           = UIKeyboardType.Default;

            if (keyboard == Keyboard.Default)
            {
                textInput.AutocapitalizationType = UITextAutocapitalizationType.Sentences;
                textInput.AutocorrectionType     = UITextAutocorrectionType.Default;
                textInput.SpellCheckingType      = UITextSpellCheckingType.Default;
            }
            else if (keyboard == Keyboard.Chat)
            {
                textInput.AutocapitalizationType = UITextAutocapitalizationType.Sentences;
                textInput.AutocorrectionType     = UITextAutocorrectionType.Yes;
            }
            else if (keyboard == Keyboard.Email)
            {
                textInput.KeyboardType = UIKeyboardType.EmailAddress;
            }
            else if (keyboard == Keyboard.Numeric)
            {
                textInput.KeyboardType = UIKeyboardType.DecimalPad;
            }
            else if (keyboard == Keyboard.Telephone)
            {
                textInput.KeyboardType = UIKeyboardType.PhonePad;
            }
            else if (keyboard == Keyboard.Text)
            {
                textInput.AutocapitalizationType = UITextAutocapitalizationType.Sentences;
                textInput.AutocorrectionType     = UITextAutocorrectionType.Yes;
                textInput.SpellCheckingType      = UITextSpellCheckingType.Yes;
            }
            else if (keyboard == Keyboard.Url)
            {
                textInput.KeyboardType = UIKeyboardType.Url;
            }
            else if (keyboard is CustomKeyboard)
            {
                var custom = (CustomKeyboard)keyboard;

                var capitalizedSentenceEnabled  = (custom.Flags & KeyboardFlags.CapitalizeSentence) == KeyboardFlags.CapitalizeSentence;
                var capitalizedWordsEnabled     = (custom.Flags & KeyboardFlags.CapitalizeWord) == KeyboardFlags.CapitalizeWord;
                var capitalizedCharacterEnabled = (custom.Flags & KeyboardFlags.CapitalizeCharacter) == KeyboardFlags.CapitalizeCharacter;
                var capitalizedNone             = (custom.Flags & KeyboardFlags.None) == KeyboardFlags.None;

                var spellcheckEnabled  = (custom.Flags & KeyboardFlags.Spellcheck) == KeyboardFlags.Spellcheck;
                var suggestionsEnabled = (custom.Flags & KeyboardFlags.Suggestions) == KeyboardFlags.Suggestions;


                UITextAutocapitalizationType capSettings = UITextAutocapitalizationType.None;

                // Sentence being first ensures that the behavior of ALL is backwards compatible
                if (capitalizedSentenceEnabled)
                {
                    capSettings = UITextAutocapitalizationType.Sentences;
                }
                else if (capitalizedWordsEnabled)
                {
                    capSettings = UITextAutocapitalizationType.Words;
                }
                else if (capitalizedCharacterEnabled)
                {
                    capSettings = UITextAutocapitalizationType.AllCharacters;
                }
                else if (capitalizedNone)
                {
                    capSettings = UITextAutocapitalizationType.None;
                }

                textInput.AutocapitalizationType = capSettings;
                textInput.AutocorrectionType     = suggestionsEnabled ? UITextAutocorrectionType.Yes : UITextAutocorrectionType.No;
                textInput.SpellCheckingType      = spellcheckEnabled ? UITextSpellCheckingType.Yes : UITextSpellCheckingType.No;
            }
        }
コード例 #17
0
 public override void TextWillChange(IUITextInput textInput)
 {
     // The app is about to change the document's contents. Perform any preparation here.
 }
コード例 #18
0
 public void TextField(IUITextInput textField, bool complete, string value)
 {
     Debug.WriteLine(value);
 }
コード例 #19
0
 public void SelectionDidChange(IUITextInput uiTextInput)
 {
 }
コード例 #20
0
 public void TextWillChange(IUITextInput textInput)
 {
 }
コード例 #21
0
 public void TextDidChange(IUITextInput textInput)
 {
 }
コード例 #22
0
 public void SelectionWillChange(IUITextInput uiTextInput)
 {
 }
コード例 #23
0
		public override void TextWillChange (IUITextInput textInput)
		{
			// The app is about to change the document's contents. Perform any preparation here.
		}
コード例 #24
0
        /////////////////////
        // POPUP DELAY END //
        /////////////////////

        // TODO: this is currently not working as intended; only called when selection changed -- iOS bug;
        public override void TextDidChange(IUITextInput textInput)
        {
            this.contextChanged();
        }