openplanet-nl / issues

Issue tracker for Openplanet.
10 stars 0 forks source link

New key presses aren't registered after blocking a keypress (probably duplicate) #591

Open XertroV opened 3 weeks ago

XertroV commented 3 weeks ago

Replication process with spectator hotkeys:

can write a little replication plugin if needed

codecat commented 2 weeks ago

Without reproduction code, there's very little I can reproduce here. This plugin shows nothing out of the ordinary for me.

void RenderInterface()
{
    if (UI::Begin("Key test")) {
        UI::Text("Keys:");
        if (UI::IsKeyDown(UI::Key::LeftShift)) {
            UI::Text("- Left shift");
        }
    }
    UI::End();
}
XertroV commented 2 weeks ago

Right you need to press another key. Oh and block the key using OnKeyPress.

XertroV commented 2 weeks ago

Ahh okay, the title was wrong. It's that new keys aren't registered, rather than IsKeyDown returning false.

void RenderInterface()
{
    if (UI::Begin("Key test")) {
        UI::Text("Press a number key while holding shift to repro");
        UI::Text("lastKey: " + tostring(lastKey));
        UI::Text("Keys:");
        if (UI::IsKeyDown(UI::Key::LeftShift)) {
            UI::Text("- Left shift");
        }
    }
    UI::End();
}

VirtualKey lastKey = VirtualKey::N;

UI::InputBlocking OnKeyPress(bool down, VirtualKey key) {
    if (down) {
        if (int(key) >= int(VirtualKey::N0) && int(key) <= int(VirtualKey::N9)) {
            lastKey = key;
            return UI::InputBlocking::Block;
        }
    }
    return UI::InputBlocking::DoNothing;
}
XertroV commented 2 weeks ago

Hmm okay, this is just the existing OnKeyPress bug by the looks.