Example #1
0
        /// <summary>
        /// Overrides the TextInput event handler to alter the text being typed
        /// if needed.
        /// </summary>
        protected override void OnTextInput(TextInputEventArgs e)
        {
            lock (_textLock)
            {
                base.OnTextInput(e);

                if (IsKanaInput)
                {
                    int caretIndexBefore = this.CaretIndex;
                    int lengthBefore = Text.Length;
                    Text = KanaHelper.RomajiToKana(Text, true);
                    this.CaretIndex = caretIndexBefore + (Text.Length - lengthBefore);
                }
            }
        }
Example #2
0
 private void OnTextEntering(object sender, TextInputEventArgs e)
 {
     if (e.Text.Length > 0 && _completionWindow != null)
     {
         var typedChar = e.Text[0];
         if (char.IsWhiteSpace(typedChar) || char.IsPunctuation(typedChar))
         {
             _completionWindow.CompletionList.RequestInsertion(e);
         }
         else
         {
             AugmentCompletionData();
         }
     }
 }
Example #3
0
        private void TextArea_TextEntering(object sender, TextInputEventArgs e)
        {
            _textEntering = true;

            if (TextArea.Selection.IsEmpty)
            {
                if (LanguageService != null && LanguageService.InputHelpers != null)
                {
                    foreach (var helper in LanguageService.InputHelpers)
                    {
                        helper.BeforeTextInput(LanguageService, DocumentAccessor, e);
                    }
                }
            }
        }
Example #4
0
 /// <summary>
 /// Manages the text unput from the user
 /// </summary>
 /// <param name="sender">Contains reference to the control/object
 /// that triggered the event</param>
 /// <param name="args">Contains the text input from the keyboard</param>
 private void TextInputHandler(object sender, TextInputEventArgs args)
 {
     if (askNameBox.Visible)
     {
         var character = args.Character;
         if (Regex.IsMatch(character.ToString(), @"^[A-Za-z0-9\-. ]$"))
         {
             askNameBox.PlayerName += character;
         }
         else if (character == '\b' && askNameBox.PlayerName.Length > 0)
         {
             askNameBox.PlayerName =
                 askNameBox.PlayerName.Remove(askNameBox.PlayerName.Length - 1);
         }
     }
 }
Example #5
0
        private void Window_TextInput(object sender, TextInputEventArgs e)
        {
            //Console.Write((int)e.Character);

            if ((int)e.Character == 8)
            {
                if (Input.Length > 0)
                {
                    Input = Input.Substring(0, Input.Length - 1);
                }
            }
            else
            {
                Input += e.Character;
            }
        }
Example #6
0
 protected override void OnTextInput(TextInputEventArgs e)
 {
     if (!string.IsNullOrEmpty(e.Text) && IsTextSearchEnabled && (e.Source == this || ItemContainerGenerator.IndexFromContainer(e.Source as IControl) != -1))
     {
         var instance = SharpTreeViewTextSearch.GetInstance(this);
         if (instance != null)
         {
             instance.Search(e.Text);
             e.Handled = true;
         }
     }
     if (!e.Handled)
     {
         base.OnTextInput(e);
     }
 }
        /// <summary>
        /// Adds the new input received by the <see cref="TextInputListener"/>.
        /// </summary>
        public static string NewInput(TextInputEventArgs textInput, string text)
        {
            KeyboardState kbState = Keyboard.GetState();

            if (kbState.IsKeyDown(Keys.Back) && !string.IsNullOrEmpty(text))
            {
                text = text.Remove(text.Length - 1);
            }
            else if (!kbState.IsKeyDown(Keys.Back))
            //We still need to check whether or not the user pressed backspace, otherwise if the text is empty, then we'll end up adding the default character.
            {
                text += textInput.Character;
            }

            return(text);
        }
 void textEditor_TextArea_TextEntered(object sender, TextInputEventArgs e)
 {
     if (e.Text == ".")
     {
         // Open code completion after the user has pressed dot:
         _completionWindow = new CompletionWindow(_textEditor.TextArea);
         IList <ICompletionData> data = _completionWindow.CompletionList.CompletionData;
         data.Add(new MyCompletionData("Item1"));
         data.Add(new MyCompletionData("Item2"));
         data.Add(new MyCompletionData("Item3"));
         _completionWindow.Show();
         _completionWindow.Closed += delegate {
             _completionWindow = null;
         };
     }
 }
Example #9
0
        private void TextArea_TextEntered(object sender, TextInputEventArgs e)
        {
            _intellisenseManager?.OnTextInput(e, CaretOffset, TextArea.Caret.Line, TextArea.Caret.Column);
            _textEntering = false;

            if (TextArea.Selection.IsEmpty)
            {
                if (LanguageService != null && LanguageService.InputHelpers != null)
                {
                    foreach (var helper in LanguageService.InputHelpers)
                    {
                        helper.AfterTextInput(LanguageService, DocumentAccessor, e);
                    }
                }
            }
        }
Example #10
0
        internal void OnTextInput(object sender, TextInputEventArgs e)
        {
            if (e.Character == '/' && !TerminalTexintput.IsFocused)
            {
                TerminalTexintput.Clear();
                TerminalTexintput.Focus(this);
            }
            TextinputBox itemFocus = (TextinputBox)_sprites.Where(s => s is TextinputBox).FirstOrDefault(t => (t as TextinputBox).IsFocused);

            if (itemFocus == null)
            {
                IsTextInputBoxFocused = false;
                return;
            }
            IsTextInputBoxFocused = true;
            KeyboardUtils.OnTextInput(sender, e, itemFocus);
        }
        void textEditor_TextArea_TextEntering(object sender, TextInputEventArgs e)
        {
            if (e.Text.Length > 0 && _completionWindow != null)
            {
                if (!char.IsLetterOrDigit(e.Text[0]))
                {
                    // Whenever a non-letter is typed while the completion window is open,
                    // insert the currently selected element.
                    _completionWindow.CompletionList.RequestInsertion(e);
                }
            }

            _insightWindow?.Hide();

            // Do not set e.Handled=true.
            // We still want to insert the character that was typed.
        }
 private void TextInputHandler(object sender, TextInputEventArgs args)
 {
     if (args.Key == Keys.OemTilde)
     {
         _isConsoleWindowOpen = !_isConsoleWindowOpen;
     }
     if (!_isConsoleWindowOpen)
     {
         return;
     }
     if (Char.IsLetter(args.Character))
     {
         _displayLine += args.Character;
     }
     if (args.Key == Keys.Back && _displayLine.Length > 0)
     {
         _displayLine = _displayLine[..^ 1];
Example #13
0
        /// <summary>
        /// Handles a key being pressed in the menu.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event args.</param>
        protected virtual void OnTextInput(object sender, TextInputEventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(e.Text))
            {
                var text  = e.Text.ToUpper();
                var focus = _registered
                            .Where(x => x.Item1 == text && x.Item2.IsEffectivelyVisible)
                            .FirstOrDefault()?.Item2;

                if (focus != null)
                {
                    focus.RaiseEvent(new RoutedEventArgs(AccessKeyHandler.AccessKeyPressedEvent));
                }

                e.Handled = true;
            }
        }
        void FilterTextBox_TextChanged(object sender, TextInputEventArgs e)
        {
            string filterString = filterTextBox.Text.Trim();

            if (filterString.Length == 0)
            {
                filterMethod = _ => true;
            }
            else
            {
                var elements = filterString.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                filterMethod = entry => elements.All(el => Contains(entry.FullName, el) || Contains(entry.FormattedVersion, el));
            }

            filteredEntries.Clear();
            filteredEntries.AddRange(gacEntries.Where(entry => filterMethod(entry)));
        }
        private void HandleTextInput(object sender, TextInputEventArgs e)
        {
            if (e.Key == Keys.OemTilde)
            {
                return;
            }

            if (IsConsoleOpen)
            {
                switch (e.Character)
                {
                case '\u007f':     // DEL
                    if (CursorPos < InputText.Length)
                    {
                        InputText = InputText.Remove(CursorPos, 1);
                    }
                    break;

                case '\b':
                    if (CursorPos > 0)
                    {
                        CursorPos--;
                        InputText = InputText.Remove(CursorPos, 1);
                    }
                    break;

                case '\r':
                case '\n':
                    if (InputText.Length > 0)
                    {
                        CursorPos = 0;
                        DevConsole.Print(" >>> " + InputText + Environment.NewLine, DevConsole.InputColor);
                        InputText = "";
                    }
                    break;

                default:
                    if (DevConsole.ConsoleFont.Characters.Contains(e.Character))
                    {
                        InputText = InputText.Insert(CursorPos, e.Character.ToString());
                        CursorPos++;
                    }
                    break;
                }
            }
        }
Example #16
0
 private void HandleTextInput(TextInputEventArgs e)
 {
     if (e.Key == Keys.Back)
     {
         HandleBackSpaceInput();
     }
     else
     {
         if (!IsTextHighlighted)
         {
             if (CursorPosition == Text.Length)
             {
                 Text += e.Character;
             }
             else if (CursorPosition == 0)
             {
                 Text = e.Character + Text;
             }
             else
             {
                 Text = Text.SubstringByIndexes(0, CursorPosition) + e.Character + Text.SubstringByIndexes(CursorPosition, Text.Length);
             }
             CursorPosition++;
         }
         else
         {
             if (HighlightStartIndex == 0 && HighlightEndIndex == Text.Length)
             {
                 Text = e.Character.ToString();
             }
             else if (HighlightStartIndex == 0)
             {
                 Text = e.Character + Text.Substring(HighlightEndIndex);
             }
             else if (HighlightEndIndex == Text.Length)
             {
                 Text = Text.Substring(0, HighlightStartIndex) + e.Character;
             }
             else
             {
                 Text = Text.SubstringByIndexes(0, HighlightStartIndex) + e.Character + Text.SubstringByIndexes(HighlightEndIndex, Text.Length);
             }
             CursorPosition = HighlightEndIndex;
         }
     }
 }
        virtual public void HandleInput(object sender, TextInputEventArgs e)
        {
            char charEntered = e.Character;

            if (charEntered == 'w')
            {
                SelectNewItem(mSelected - 1);
            }
            if (charEntered == 's')
            {
                SelectNewItem(mSelected + 1);
            }
            if (charEntered == '\r')
            {
                mItems[mSelected].Activate();
            }
        }
Example #18
0
        public static void Window_TextInput(object sender, TextInputEventArgs e)
        {
            if (_textEditable != null)
            {
                switch (e.Key)
                {
                case Keys.Enter:
                case Keys.Back:
                case Keys.Delete:
                    break;

                default:
                    _textEditable.Append(e.Character);
                    break;
                }
            }
        }
Example #19
0
 private void OnTextInput(object sender, TextInputEventArgs args)
 {
     //Backspace removes the last character
     if (args.Key == Keys.Back)
     {
         input = input.Substring(0, MathHelper.Max(input.Length - 1, 0));
     }
     //Enter adds a new line
     else if (args.Key == Keys.Enter)
     {
         input += '\n';
     }
     //Only add the character if it's supported by the font
     else if (fonts[fontIndex].Glyphs.ContainsKey(args.Character))
     {
         input += args.Character;
     }
 }
Example #20
0
        protected static void TriggerTextInput(IntPtr sender, IntPtr sel, IntPtr textPtr)
        {
            var obj = Runtime.GetNSObject(sender);

            var handler = GetHandler(obj) as IMacViewHandler;

            if (handler != null)
            {
                var text = (string)Messaging.GetNSObject <NSString>(textPtr);
                var args = new TextInputEventArgs(text);
                handler.Callback.OnTextInput(handler.Widget, args);
                if (args.Cancel)
                {
                    return;
                }
            }
            Messaging.void_objc_msgSendSuper_IntPtr(obj.SuperHandle, sel, textPtr);
        }
Example #21
0
        public void OnTextInput(TextInputEventArgs args)
        {
            DebugPrintChar("text", args.Character);

            // HACK: This seems to fix a bug: after pressing some keys like backspace or cursor left,
            // a Noesis textbox would ignore the next incoming char.
            // Passing None to Noesis seems a workaround.
            // Need to figure out where the bug comes from, could be our code
            m_RootView.KeyDown(Noesis.Key.None);

            var newChar = args.Character;

            // HACK: Space seems to be handled both as a control and textual key by Noesis, so don't pass it as a text char.
            if (newChar != ' ')
            {
                OnChar(newChar);
            }
        }
Example #22
0
        async void textEditor_TextArea_TextEntered(object sender, TextInputEventArgs e)
        {
            try
            {
                codeService = CodeAnalysisService.LoadDocument(_editor.Document.Text);

                if (e.Text == "(")
                {
                    var p = await codeService.GetMethodSignature(_editor.CaretOffset - 2);

                    if (p != null)
                    {
                        _insightWindow         = new OverloadInsightWindow(_editor.TextArea);
                        _insightWindow.Closed += (s, a) => _insightWindow = null;

                        _insightWindow.Provider = new OverloadProvider(p);
                        _insightWindow.Show();
                        return;
                    }
                }
                if (await codeService.ShouldTriggerCompletion(_editor.CaretOffset))
                {
                    _completionWindow         = new CompletionWindow(_editor.TextArea);
                    _completionWindow.Closed += (o, args) => _completionWindow = null;

                    var data = await CodeAnalysisService.LoadDocument(_editor.Document.Text).GetCompletitionDataAt(_editor.CaretOffset);

                    if (data.Count == 0 || _completionWindow == null)
                    {
                        return;
                    }

                    foreach (var d in data)
                    {
                        _completionWindow.CompletionList.CompletionData.Add(d);
                    }

                    _completionWindow.StartOffset -= 1;

                    _completionWindow.Show();
                }
            }
            catch { }
        }
        private void OnHexTextChanging(object sender, TextInputEventArgs args)
        {
            // If we're in the process of updating controls in response to a color change,
            // then we don't want to do anything in response to a control being updated,
            // since otherwise we'll get into an infinite loop of updating.
            if (m_updatingControls)
            {
                return;
            }

            var hexTextBox     = (TextBox)sender;
            var hexTextBoxText = hexTextBox.Text;

            // If the user hasn't entered a #, we'll do that for them, keeping the cursor
            // where it was before.
            if (hexTextBoxText.Length == 0 || hexTextBoxText[0] != '#')
            {
                hexTextBox.Text = hexTextBoxText = "#" + hexTextBoxText;
                // TODO should it use saved before length?
                hexTextBox.CaretIndex = hexTextBoxText.Length;
            }

            // We'll respond to the text change if the user has entered a valid value.
            // Otherwise, we'll do nothing except mark the text box's contents as invalid.
            var isAlphaEnabled = IsAlphaEnabled;

            if (Color.TryParse(hexTextBoxText, out var parsedColor))
            {
                var rgbValue   = new Rgb(parsedColor.R / 255.0, parsedColor.G / 255.0, parsedColor.B / 255.0);
                var alphaValue = parsedColor.A / 255.0;
                if (!isAlphaEnabled)
                {
                    alphaValue = 1.0;
                }

                m_isFocusedTextBoxValid = true;
                UpdateColor(ApplyConstraintsToRgbColor(rgbValue), ColorUpdateReason.HexTextBoxChanged);
                UpdateColor(alphaValue, ColorUpdateReason.HexTextBoxChanged);
            }
            else
            {
                m_isFocusedTextBoxValid = false;
            }
        }
        private async Task OnTextEntering(TextInputEventArgs e)
        {
            if (e.Text.Length == 1 || e.Text == Environment.NewLine)
            {
                char inserting = e.Text[0];

                if (CompletionWindow.IsVisible)
                {
                    try
                    {
                        e.Handled = await CompletionWindow.CheckAndCommit(inserting);
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine("Error while checking completion commit: {0}", ex.Message);
                    }
                }
            }
        }
Example #25
0
        void HandleTextInput(object sender, swi.TextCompositionEventArgs e)
        {
            var tiargs = new TextInputEventArgs(e.Text);

            Callback.OnTextInput(Widget, tiargs);
            if (tiargs.Cancel)
            {
                e.Handled = true;
                return;
            }

            foreach (var keyChar in e.Text)
            {
                var key  = Keys.None;
                var args = new KeyEventArgs(key, KeyEventType.KeyDown, keyChar);
                Callback.OnKeyDown(Widget, args);
                e.Handled |= args.Handled;
            }
        }
Example #26
0
        public void TextInp(object sender, TextInputEventArgs args)
        {
            if (open)
            {
                bool addtext = false;
                foreach (var character in font.Characters)
                {
                    if (args.Character.Equals(character))
                    {
                        addtext = true;
                    }
                }

                if (addtext)
                {
                    text += args.Character;
                }
            }
        }
Example #27
0
        private void SetText(object sender, TextInputEventArgs args)
        {
            if (ActiveField == -1)
            {
                return;
            }

            switch (args.Key)
            {
            case Keys.Escape: Main.instance.MenuUI.GoBack(); break;

            case Keys.Back: Field[ActiveField].Backspace(); break;

            case Keys.Tab:
            case Keys.Enter: ActiveField++; break;

            default: Field[ActiveField].Write(args.Character); break;
            }
        }
        protected override void OnTextInput(TextInputEventArgs e)
        {
            if (!e.Handled)
            {
                if (!IsTextSearchEnabled)
                {
                    return;
                }

                StopTextSearchTimer();

                _textSearchTerm += e.Text;

                bool Match(ItemContainerInfo info)
                {
                    if (info.ContainerControl is AvaloniaObject ao && ao.IsSet(TextSearch.TextProperty))
                    {
                        var searchText = ao.GetValue(TextSearch.TextProperty);

                        if (searchText?.StartsWith(_textSearchTerm, StringComparison.OrdinalIgnoreCase) == true)
                        {
                            return(true);
                        }
                    }

                    return(info.ContainerControl is IContentControl control &&
                           control.Content?.ToString()?.StartsWith(_textSearchTerm, StringComparison.OrdinalIgnoreCase) == true);
                }

                var info = ItemContainerGenerator?.Containers.FirstOrDefault(Match);

                if (info != null)
                {
                    SelectedIndex = info.Index;
                }

                StartTextSearchTimer();

                e.Handled = true;
            }

            base.OnTextInput(e);
        }
Example #29
0
        private void HandleInput(object sender, TextInputEventArgs e)
        {
            char charEntered = e.Character;

            List <Action <char> > events = new List <Action <char> >();

            if (_keyEvents.TryGetValue(charEntered, out events))
            {
                foreach (Action <char> currentEvent in events)
                {
                    currentEvent.Invoke(charEntered);
                }
            }

            foreach (Action <char> currentEvent in _everyKeyEvent)
            {
                currentEvent.Invoke(charEntered);
            }
        }
Example #30
0
        void TextInput(object sender, TextInputEventArgs args)
        {
            if (IsFocused)
            {
                if (!IllegalKeys.Contains(args.Key))
                {
                    if (InputTextComponent.Font.Characters.Contains(args.Character))
                    {
                        InputText += args.Character;
                    }
                }
                else if (args.Key == Keys.Back && InputText != "")
                {
                    InputText = InputText.Substring(0, InputText.Length - 1);
                }

                UpdateCaret();
            }
        }
Example #31
0
		public override void KeyDown (NSEvent theEvent)
		{
			var keyArgs = theEvent.ToXwtKeyEventArgs ();
			context.InvokeUserCode (delegate {
				eventSink.OnKeyPressed (keyArgs);
			});
			if (keyArgs.Handled)
				return;

			var textArgs = new TextInputEventArgs (theEvent.Characters);
			if (!String.IsNullOrEmpty(theEvent.Characters))
				context.InvokeUserCode (delegate {
					eventSink.OnTextInput (textArgs);
				});
			if (textArgs.Handled)
				return;

			base.KeyDown (theEvent);
		}
Example #32
0
 void WidgetPreviewTextInputHandler(object sender, System.Windows.Input.TextCompositionEventArgs e)
 {
     TextInputEventArgs args = new TextInputEventArgs(e.Text);
     Context.InvokeUserCode(delegate
     {
         eventSink.OnTextInput(args);
     });
     if (args.Handled)
         e.Handled = true;
 }