mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-06 04:58:47 +02:00
23
imgui.cpp
23
imgui.cpp
@ -1169,6 +1169,7 @@ ImGuiIO::ImGuiIO()
|
||||
for (int i = 0; i < IM_ARRAYSIZE(MouseDownDuration); i++) MouseDownDuration[i] = MouseDownDurationPrev[i] = -1.0f;
|
||||
for (int i = 0; i < IM_ARRAYSIZE(KeysData); i++) { KeysData[i].DownDuration = KeysData[i].DownDurationPrev = -1.0f; }
|
||||
for (int i = 0; i < IM_ARRAYSIZE(NavInputsDownDuration); i++) NavInputsDownDuration[i] = -1.0f;
|
||||
AppAcceptingEvents = true;
|
||||
BackendUsingLegacyKeyArrays = (ImS8)-1;
|
||||
BackendUsingLegacyNavInputArray = true; // assume using legacy array until proven wrong
|
||||
}
|
||||
@ -1181,7 +1182,7 @@ void ImGuiIO::AddInputCharacter(unsigned int c)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
||||
if (c == 0)
|
||||
if (c == 0 || !AppAcceptingEvents)
|
||||
return;
|
||||
|
||||
ImGuiInputEvent e;
|
||||
@ -1195,7 +1196,7 @@ void ImGuiIO::AddInputCharacter(unsigned int c)
|
||||
// we should save the high surrogate.
|
||||
void ImGuiIO::AddInputCharacterUTF16(ImWchar16 c)
|
||||
{
|
||||
if (c == 0 && InputQueueSurrogate == 0)
|
||||
if ((c == 0 && InputQueueSurrogate == 0) || !AppAcceptingEvents)
|
||||
return;
|
||||
|
||||
if ((c & 0xFC00) == 0xD800) // High surrogate, must save
|
||||
@ -1229,6 +1230,8 @@ void ImGuiIO::AddInputCharacterUTF16(ImWchar16 c)
|
||||
|
||||
void ImGuiIO::AddInputCharactersUTF8(const char* utf8_chars)
|
||||
{
|
||||
if (!AppAcceptingEvents)
|
||||
return;
|
||||
while (*utf8_chars != 0)
|
||||
{
|
||||
unsigned int c = 0;
|
||||
@ -1267,7 +1270,7 @@ void ImGuiIO::ClearInputKeys()
|
||||
void ImGuiIO::AddKeyAnalogEvent(ImGuiKey key, bool down, float analog_value)
|
||||
{
|
||||
//if (e->Down) { IMGUI_DEBUG_LOG("AddKeyEvent() Key='%s' %d, NativeKeycode = %d, NativeScancode = %d\n", ImGui::GetKeyName(e->Key), e->Down, e->NativeKeycode, e->NativeScancode); }
|
||||
if (key == ImGuiKey_None)
|
||||
if (key == ImGuiKey_None || !AppAcceptingEvents)
|
||||
return;
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
||||
@ -1308,6 +1311,8 @@ void ImGuiIO::AddKeyAnalogEvent(ImGuiKey key, bool down, float analog_value)
|
||||
|
||||
void ImGuiIO::AddKeyEvent(ImGuiKey key, bool down)
|
||||
{
|
||||
if (!AppAcceptingEvents)
|
||||
return;
|
||||
AddKeyAnalogEvent(key, down, down ? 1.0f : 0.0f);
|
||||
}
|
||||
|
||||
@ -1336,11 +1341,19 @@ void ImGuiIO::SetKeyEventNativeData(ImGuiKey key, int native_keycode, int native
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set master flag for accepting key/mouse/text events (default to true). Useful if you have native dialog boxes that are interrupting your application loop/refresh, and you want to disable events being queued while your app is frozen.
|
||||
void ImGuiIO::SetAppAcceptingEvents(bool accepting_events)
|
||||
{
|
||||
AppAcceptingEvents = accepting_events;
|
||||
}
|
||||
|
||||
// Queue a mouse move event
|
||||
void ImGuiIO::AddMousePosEvent(float x, float y)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
||||
if (!AppAcceptingEvents)
|
||||
return;
|
||||
|
||||
ImGuiInputEvent e;
|
||||
e.Type = ImGuiInputEventType_MousePos;
|
||||
@ -1355,6 +1368,8 @@ void ImGuiIO::AddMouseButtonEvent(int mouse_button, bool down)
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
||||
IM_ASSERT(mouse_button >= 0 && mouse_button < ImGuiMouseButton_COUNT);
|
||||
if (!AppAcceptingEvents)
|
||||
return;
|
||||
|
||||
ImGuiInputEvent e;
|
||||
e.Type = ImGuiInputEventType_MouseButton;
|
||||
@ -1369,7 +1384,7 @@ void ImGuiIO::AddMouseWheelEvent(float wheel_x, float wheel_y)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
||||
if (wheel_x == 0.0f && wheel_y == 0.0f)
|
||||
if ((wheel_x == 0.0f && wheel_y == 0.0f) || !AppAcceptingEvents)
|
||||
return;
|
||||
|
||||
ImGuiInputEvent e;
|
||||
|
Reference in New Issue
Block a user