desjarlais/Scintilla.NET

Setting e.Handled=true in the KeyDown event handler has no effect

Closed this issue · 2 comments

Well I'm trying to activate (show) the autocomplete list box always when the user hits CTRL+SPACE in the Scintilla edit control, independent of what was actually typed so far. (I'm using V5.3.2.9)

Here's my code:

        private void edScintillaSql_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Control && e.KeyCode == Keys.Space && sender is Scintilla sc)
            {
                string s = "Some|Prepared|Entries";
                if (!string.IsNullOrEmpty(s))
                    sc.AutoCShow(-1, s);
                 e.Handled = true;
            }
        }

This actually already works fine. But when the user hits that key combination (Control+Space), a space character is still inserted, even though I try to suppress it by setting e.Handled = true. When the user then picks an entry from the list that space is removed again. But if he/she doesn't, the space input remains in the text.

How can I make it so the the space doesn't get instered at all?

Thanks

Setting e.SuppressKeyPress = true; should work in this case. This also sets e.Handled automatically.

Super. Works like a charm. Thanks!