Skip to content

AutoComplete with TAB #258

Open
Open
@Arkinetic

Description

@Arkinetic

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions