jvcleave / ofxImGui

Use ImGui in openFrameworks
296 stars 124 forks source link

Duplicate key input #18

Closed Geistyp closed 8 years ago

Geistyp commented 8 years ago
void BaseEngine::onKeyPressed(ofKeyEventArgs& event)
{
    int key = event.keycode;
    io->KeysDown[key] = true;
    io->AddInputCharacter((unsigned short)event.codepoint);
}

void EngineGLFW::onKeyReleased(ofKeyEventArgs& event)
{
    int key = event.keycode;
    io->KeysDown[key] = false;

    io->KeyCtrl  = io->KeysDown[GLFW_KEY_LEFT_CONTROL] || io->KeysDown[GLFW_KEY_RIGHT_CONTROL];
    io->KeyShift = io->KeysDown[GLFW_KEY_LEFT_SHIFT]   || io->KeysDown[GLFW_KEY_RIGHT_SHIFT];
    io->KeyAlt   = io->KeysDown[GLFW_KEY_LEFT_ALT]     || io->KeysDown[GLFW_KEY_RIGHT_ALT];
    if(key < GLFW_KEY_ESCAPE)
    {
        io->AddInputCharacter((unsigned short)event.codepoint);
    }
}

press and release add same codepoint, if I try input 'a', input text will be 'aa'

jvcleave commented 8 years ago

Thanks! I have commented it out of the BaseEngine