mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-11 01:11:48 +08:00
Fix Release ghost pressing of key backspace, del, ...
Add debug log for imgui update key data - aka key events
This commit is contained in:
parent
8a1fc4b16b
commit
58a825dd91
@ -257,20 +257,37 @@ bool ImGuiWrapper::update_key_data(wxKeyEvent &evt)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
auto to_string = [](wxEventType type) -> std::string {
|
||||||
|
if (type == wxEVT_CHAR) return "Char";
|
||||||
|
if (type == wxEVT_KEY_DOWN) return "KeyDown";
|
||||||
|
if (type == wxEVT_KEY_UP) return "KeyUp";
|
||||||
|
return "Other";
|
||||||
|
};
|
||||||
|
|
||||||
if (evt.GetEventType() == wxEVT_CHAR) {
|
wxEventType type = evt.GetEventType();
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
BOOST_LOG_TRIVIAL(debug) << "ImGui - key event(" << to_string(type) << "):"
|
||||||
|
//<< " Unicode(" << evt.GetUnicodeKey() << ")"
|
||||||
|
<< " KeyCode(" << evt.GetKeyCode() << ")";
|
||||||
|
|
||||||
|
if (type == wxEVT_CHAR) {
|
||||||
// Char event
|
// Char event
|
||||||
const auto key = evt.GetUnicodeKey();
|
const auto key = evt.GetUnicodeKey();
|
||||||
|
unsigned int key_u = static_cast<unsigned int>(key);
|
||||||
|
// Release BackSpace, Delete, ... when miss wxEVT_KEY_UP event
|
||||||
|
if (key_u >= 0 && key_u < IM_ARRAYSIZE(io.KeysDown) && io.KeysDown[key_u]) {
|
||||||
|
io.KeysDown[key_u] = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (key != 0) {
|
if (key != 0) {
|
||||||
io.AddInputCharacter(key);
|
io.AddInputCharacter(key);
|
||||||
}
|
}
|
||||||
} else {
|
} else if (type == wxEVT_KEY_DOWN || type == wxEVT_KEY_UP) {
|
||||||
// Key up/down event
|
// Key up/down event
|
||||||
int key = evt.GetKeyCode();
|
int key = evt.GetKeyCode();
|
||||||
wxCHECK_MSG(key >= 0 && key < IM_ARRAYSIZE(io.KeysDown), false, "Received invalid key code");
|
wxCHECK_MSG(key >= 0 && key < IM_ARRAYSIZE(io.KeysDown), false, "Received invalid key code");
|
||||||
|
|
||||||
io.KeysDown[key] = evt.GetEventType() == wxEVT_KEY_DOWN;
|
io.KeysDown[key] = (type == wxEVT_KEY_DOWN);
|
||||||
io.KeyShift = evt.ShiftDown();
|
io.KeyShift = evt.ShiftDown();
|
||||||
io.KeyCtrl = evt.ControlDown();
|
io.KeyCtrl = evt.ControlDown();
|
||||||
io.KeyAlt = evt.AltDown();
|
io.KeyAlt = evt.AltDown();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user