Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoComplete with TAB #258

Open
Arkinetic opened this issue Jun 11, 2023 · 0 comments
Open

AutoComplete with TAB #258

Arkinetic opened this issue Jun 11, 2023 · 0 comments

Comments

@Arkinetic
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant