alaingalvan/CrossWindow

Text input

fhoenig opened this issue · 1 comments

Project looks great and clean. However, how do you handle char input?
WM_UNICHAR etc.

Hey @fhoenig, currently for Win32 key events are propigated at:

Win32EventQueue.cpp Line 349

So should your application need to type out character input you can listen to these events and call xwin::convertKeyToString(xwin::Key key);

if (e.type == xwin::EventType::Keyboard)
{
    xwin::KeyboardData& kd = e.data.keyboard;
    size_t kid = static_cast<size_t>(kd.key);
    if (kid < 256)
    {
        if (kd.state == xwin::ButtonState::Released)
        {
            charBuf += xwin::convertKeyToString(kd.key);
        }
    }
}

EDIT: I'll update the sister repo's examples to include an instance of character input using ImGui.