Browse Source

Demo: fix casing swap demo inserting garbage characters when typing lowercase letters (#6482)

Christian Fillion 2 years ago
parent
commit
f1777f9517
1 changed files with 2 additions and 2 deletions
  1. 2 2
      imgui_demo.cpp

+ 2 - 2
imgui_demo.cpp

@@ -1393,8 +1393,8 @@ static void ShowDemoWindowWidgets()
                 // Modify character input by altering 'data->Eventchar' (ImGuiInputTextFlags_CallbackCharFilter callback)
                 // Modify character input by altering 'data->Eventchar' (ImGuiInputTextFlags_CallbackCharFilter callback)
                 static int FilterCasingSwap(ImGuiInputTextCallbackData* data)
                 static int FilterCasingSwap(ImGuiInputTextCallbackData* data)
                 {
                 {
-                    if (data->EventChar >= 'a' && data->EventChar <= 'z')       { data->EventChar = data->EventChar - 'A' - 'a'; } // Lowercase becomes uppercase
-                    else if (data->EventChar >= 'A' && data->EventChar <= 'Z')  { data->EventChar = data->EventChar + 'a' - 'A'; } // Uppercase becomes lowercase
+                    if (data->EventChar >= 'a' && data->EventChar <= 'z')       { data->EventChar -= 'a' - 'A'; } // Lowercase becomes uppercase
+                    else if (data->EventChar >= 'A' && data->EventChar <= 'Z')  { data->EventChar += 'a' - 'A'; } // Uppercase becomes lowercase
                     return 0;
                     return 0;
                 }
                 }