PavelTorgashov / FastColoredTextBox

Fast Colored TextBox for Syntax Highlighting. The text editor component for .NET.
Other
1.21k stars 463 forks source link

AutoComplete with TAB #258

Open Arkinetic opened 1 year ago

Arkinetic commented 1 year ago

Hello, how can i make the textbox accept the autocomplete suggestion by pressing TAB, i currently have sometihng like this: private void editor_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Tab && autoCompleteMenu.Visible) { // Get the currently displayed suggestion AutocompleteItem displayedSuggestion = autoCompleteMenu.Fragment.GetSuggestedItems().FirstOrDefault();

            if (displayedSuggestion != null)
            {
                // Get the text of the displayed suggestion
                string displayedText = displayedSuggestion.Text;

                if (!string.IsNullOrEmpty(displayedText))
                {
                    // Insert the displayed suggestion at the current caret position
                    textBox.InsertText(displayedText);
                    e.Handled = true; // Prevent the TAB key from moving focus to the next control
                }
            }
        }
    }
    P.S this was gpt generated