Fix crash on Shift press.

This commit is contained in:
w1naenator 2025-03-27 16:40:44 +02:00
parent 297a17b237
commit bc0319e7ed

View File

@ -372,6 +372,7 @@ void ImeDialogUi::DrawKeyboard() {
ImGui::NewLine(); ImGui::NewLine();
}; };
// SHIFT status label
if (shift_enabled) { if (shift_enabled) {
SetCursorPosX(20.0f); SetCursorPosX(20.0f);
TextColored(ImVec4(0.2f, 0.6f, 1.0f, 1.0f), "SHIFT ENABLED"); TextColored(ImVec4(0.2f, 0.6f, 1.0f, 1.0f), "SHIFT ENABLED");
@ -383,14 +384,16 @@ void ImeDialogUi::DrawKeyboard() {
SetCursorPosX(20.0f); SetCursorPosX(20.0f);
if (shift_enabled) // Fix: safely push/pop style only if shift was enabled before clicking
bool highlight = shift_enabled;
if (highlight)
PushStyleColor(ImGuiCol_Button, ImVec4(0.2f, 0.6f, 1.0f, 1.0f)); PushStyleColor(ImGuiCol_Button, ImVec4(0.2f, 0.6f, 1.0f, 1.0f));
if (Button("SHIFT", ImVec2(75, 35))) { if (Button("SHIFT", ImVec2(75, 35))) {
shift_enabled = !shift_enabled; shift_enabled = !shift_enabled;
} }
if (shift_enabled) if (highlight)
PopStyleColor(); PopStyleColor();
SameLine(); SameLine();
@ -425,6 +428,7 @@ void ImeDialogUi::DrawKeyboard() {
} }
int ImeDialogUi::InputTextCallback(ImGuiInputTextCallbackData* data) { int ImeDialogUi::InputTextCallback(ImGuiInputTextCallbackData* data) {
ImeDialogUi* ui = static_cast<ImeDialogUi*>(data->UserData); ImeDialogUi* ui = static_cast<ImeDialogUi*>(data->UserData);
ASSERT(ui); ASSERT(ui);