Exemplo n.º 1
0
        private void SetText(string text)
        {
            _changedCount++;
            while (TextDocumentProxy.HasText)
            {
                TextDocumentProxy.DeleteBackward();
            }

            TextDocumentProxy.InsertText(text);
        }
Exemplo n.º 2
0
        private async void Input(string text)
        {
            if (!IsLoaded)
            {
                return;
            }

            if (text == _lastText)
            {
                return;
            }

            _lastText = text;

            if (_inputingTexts.Any())
            {
                _inputingTexts.Enqueue(text);
                return;
            }

            _inputingTexts.Enqueue(text);

            while (_inputingTexts.Any())
            {
                var current = _inputingTexts.Dequeue();
                if (_inputingTexts.Any())
                {
                    var next = _inputingTexts.Peek();
                    if (current == "\n")
                    {
                        TextDocumentProxy.InsertText("\n");
                        await Task.Delay(100);
                    }
                    else if (next == "\n")
                    {
                        SetText(current);
                        await Task.Delay(100);
                    }
                    else
                    {
                        continue;
                    }
                }
                else
                {
                    SetText(current);
                    await Task.Delay(100);
                }
            }

            UpdateCounts();
        }
        partial void KeyPress(NSObject sender)
        {
            var button = sender as UIButton;
            var text   = button.Title(UIControlState.Normal);

            Console.WriteLine(text);

            if (!string.IsNullOrEmpty(text))
            {
                TextDocumentProxy.InsertText(text);

                if (isShiftPressed)
                {
                    UpdateShiftText(false);
                    UpdateKeyboardLayout();
                }
            }

            Anumate(button);
        }
        private void SetText(string text)
        {
            BeginInvokeOnMainThread(SetTextInner);

            void SetTextInner()
            {
                try
                {
                    _changedCount++;
                    while (TextDocumentProxy.HasText)
                    {
                        TextDocumentProxy.DeleteBackward();
                    }

                    TextDocumentProxy.InsertText(text);
                }
                catch (Exception ex)
                {
                    Debug(ex);
                }
            }
        }
 partial void SpacePressed(NSObject sender)
 {
     TextDocumentProxy.InsertText(" ");
 }
 partial void ReturnPressed(NSObject sender)
 {
     TextDocumentProxy.InsertText("\n");
 }
 partial void BackspacePressed(NSObject sender)
 {
     TextDocumentProxy.DeleteBackward();
 }
 void PrintWord(object sender, EventArgs e)
 {
     TextDocumentProxy.InsertText(SingleWord);
 }
        private void Input(string text)
        {
            BeginInvokeOnMainThread(() =>
            {
                try
                {
                    InputInner();
                }
                catch (Exception ex)
                {
                    Debug(ex);
                }
            });

            async void InputInner()
            {
                if (!IsLoaded)
                {
                    return;
                }

                if (text == _lastText)
                {
                    return;
                }

                _lastText = text;

                if (_inputingTexts.Any())
                {
                    _inputingTexts.Enqueue(text);
                    return;
                }

                _inputingTexts.Enqueue(text);

                while (_inputingTexts.Any())
                {
                    var current = _inputingTexts.Dequeue();
                    if (_inputingTexts.Any())
                    {
                        var next = _inputingTexts.Peek();
                        if (current == "\n")
                        {
                            TextDocumentProxy.InsertText("\n");
                            await Task.Delay(100);
                        }
                        else if (next == "\n")
                        {
                            SetText(current);
                            await Task.Delay(100);
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        SetText(current);
                        await Task.Delay(100);
                    }
                }

                UpdateCounts();
            }
        }
 public void PrintWord()
 {
     TextDocumentProxy.InsertText(SingleWord);
 }