eranif / codelite

A multi purpose IDE specialized in C/C++/Rust/Python/PHP and Node.js. Written in C++
https://codelite.org
GNU General Public License v2.0
2.16k stars 461 forks source link

Keyboard search in tree controls is shown for non-typing keys #1012

Closed MaartenBent closed 9 years ago

MaartenBent commented 9 years ago

Almost all keys on the keyboard trigger the search function (numpad keys; ins, del home, etc; capslock, scroll lock).

These keys should probably be excluded. Numpad could be useful but currently it generates strange characters.

eranif commented 9 years ago

Thanks for reporting this. This feature is new and still under improvements. If you find something else with it, please let me know

MaartenBent commented 9 years ago

You should probably use event.GetUnicodeKey() instead of event.GetKeyCode(), as wxWidgets suggests. Also the first character is capitalized while shift is being disabled.. If shift is not used as an accelerator for some functions, you could allow it like:

    if ((event.GetModifiers() != wxMOD_NONE && event.GetModifiers() != wxMOD_SHIFT) || ignoreKeys.count(ch)) {
        event.Skip();
        return;
    }

    if (!m_text->IsShown()) {
        DoShowTextBox();
    }

    wxString chStr(event.GetUnicodeKey());
    if (!event.ShiftDown())
        chStr.MakeLower();
    m_text->ChangeValue(chStr);
MaartenBent commented 9 years ago

One last suggestion. You could also use the following instead of using the ignore list:

    wxChar ch = event.GetUnicodeKey();
    if((event.GetModifiers() != wxMOD_NONE && event.GetModifiers() != wxMOD_SHIFT) || ch == WXK_NONE) {
        event.Skip();
        return;
    }

    if(!m_text->IsShown()) {
        DoShowTextBox();
    }

    wxString chStr(ch);

(Only shortly tested)

eranif commented 9 years ago

This does not work for all keyboard keys (e.g. ESCAPE, BACKSPACE)