mirror of
https://github.com/Drezil/imgui.git
synced 2025-01-11 16:26:35 +00:00
ImGuiInputTextFlags_CallbackCharFilter can return 1 to filter character
This commit is contained in:
parent
b73484a66b
commit
2df4735904
@ -5255,7 +5255,8 @@ static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags f
|
|||||||
callback_data.EventChar = c;
|
callback_data.EventChar = c;
|
||||||
callback_data.Flags = flags;
|
callback_data.Flags = flags;
|
||||||
callback_data.UserData = user_data;
|
callback_data.UserData = user_data;
|
||||||
callback(&callback_data);
|
if (callback(&callback_data) != 0)
|
||||||
|
return false;
|
||||||
*p_char = callback_data.EventChar;
|
*p_char = callback_data.EventChar;
|
||||||
if (!callback_data.EventChar)
|
if (!callback_data.EventChar)
|
||||||
return false;
|
return false;
|
||||||
@ -8352,7 +8353,7 @@ void ImGui::ShowTestWindow(bool* opened)
|
|||||||
static char buf2[64] = ""; ImGui::InputText("decimal", buf2, 64, ImGuiInputTextFlags_CharsDecimal);
|
static char buf2[64] = ""; ImGui::InputText("decimal", buf2, 64, ImGuiInputTextFlags_CharsDecimal);
|
||||||
static char buf3[64] = ""; ImGui::InputText("hexadecimal", buf3, 64, ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase);
|
static char buf3[64] = ""; ImGui::InputText("hexadecimal", buf3, 64, ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase);
|
||||||
static char buf4[64] = ""; ImGui::InputText("uppercase", buf4, 64, ImGuiInputTextFlags_CharsUppercase);
|
static char buf4[64] = ""; ImGui::InputText("uppercase", buf4, 64, ImGuiInputTextFlags_CharsUppercase);
|
||||||
struct TextFilters { static int FilterNoSpace(ImGuiTextEditCallbackData* data) { if (data->EventChar == ' ') data->EventChar = 0; return 0; } };
|
struct TextFilters { static int FilterNoSpace(ImGuiTextEditCallbackData* data) { if (data->EventChar == ' ') return 1; return 0; } };
|
||||||
static char buf5[64] = ""; ImGui::InputText("custom: no spaces", buf5, 64, ImGuiInputTextFlags_CallbackCharFilter, TextFilters::FilterNoSpace);
|
static char buf5[64] = ""; ImGui::InputText("custom: no spaces", buf5, 64, ImGuiInputTextFlags_CallbackCharFilter, TextFilters::FilterNoSpace);
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
}
|
}
|
||||||
|
2
imgui.h
2
imgui.h
@ -394,7 +394,7 @@ enum ImGuiInputTextFlags_
|
|||||||
ImGuiInputTextFlags_CallbackCompletion = 1 << 5, // Call user function on pressing TAB (for completion handling)
|
ImGuiInputTextFlags_CallbackCompletion = 1 << 5, // Call user function on pressing TAB (for completion handling)
|
||||||
ImGuiInputTextFlags_CallbackHistory = 1 << 6, // Call user function on pressing Up/Down arrows (for history handling)
|
ImGuiInputTextFlags_CallbackHistory = 1 << 6, // Call user function on pressing Up/Down arrows (for history handling)
|
||||||
ImGuiInputTextFlags_CallbackAlways = 1 << 7, // Call user function every time
|
ImGuiInputTextFlags_CallbackAlways = 1 << 7, // Call user function every time
|
||||||
ImGuiInputTextFlags_CallbackCharFilter = 1 << 8 // Call user function to filter character. Modify data->EventChar to replace/filter input.
|
ImGuiInputTextFlags_CallbackCharFilter = 1 << 8 // Call user function to filter character. Modify data->EventChar to replace/filter input, or return 1 to discard character.
|
||||||
//ImGuiInputTextFlags_AlignCenter = 1 << 6,
|
//ImGuiInputTextFlags_AlignCenter = 1 << 6,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user