Inputs: added a unique event identifier in ImGuiInputEvent.
diff --git a/imgui.cpp b/imgui.cpp
index 1b8423f..e15a934 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -1269,6 +1269,7 @@
ImGuiInputEvent e;
e.Type = ImGuiInputEventType_Text;
e.Source = ImGuiInputSource_Keyboard;
+ e.EventId = g.InputEventsNextEventId++;
e.Text.Char = c;
g.InputEventsQueue.push_back(e);
}
@@ -1407,6 +1408,7 @@
ImGuiInputEvent e;
e.Type = ImGuiInputEventType_Key;
e.Source = ImGui::IsGamepadKey(key) ? ImGuiInputSource_Gamepad : ImGuiInputSource_Keyboard;
+ e.EventId = g.InputEventsNextEventId++;
e.Key.Key = key;
e.Key.Down = down;
e.Key.AnalogValue = analog_value;
@@ -1471,6 +1473,7 @@
ImGuiInputEvent e;
e.Type = ImGuiInputEventType_MousePos;
e.Source = ImGuiInputSource_Mouse;
+ e.EventId = g.InputEventsNextEventId++;
e.MousePos.PosX = pos.x;
e.MousePos.PosY = pos.y;
e.MouseWheel.MouseSource = g.InputEventsNextMouseSource;
@@ -1494,6 +1497,7 @@
ImGuiInputEvent e;
e.Type = ImGuiInputEventType_MouseButton;
e.Source = ImGuiInputSource_Mouse;
+ e.EventId = g.InputEventsNextEventId++;
e.MouseButton.Button = mouse_button;
e.MouseButton.Down = down;
e.MouseWheel.MouseSource = g.InputEventsNextMouseSource;
@@ -1513,6 +1517,7 @@
ImGuiInputEvent e;
e.Type = ImGuiInputEventType_MouseWheel;
e.Source = ImGuiInputSource_Mouse;
+ e.EventId = g.InputEventsNextEventId++;
e.MouseWheel.WheelX = wheel_x;
e.MouseWheel.WheelY = wheel_y;
e.MouseWheel.MouseSource = g.InputEventsNextMouseSource;
@@ -1541,6 +1546,7 @@
ImGuiInputEvent e;
e.Type = ImGuiInputEventType_Focus;
+ e.EventId = g.InputEventsNextEventId++;
e.AppFocused.Focused = focused;
g.InputEventsQueue.push_back(e);
}
diff --git a/imgui_internal.h b/imgui_internal.h
index b4abbe0..cd1c1e8 100644
--- a/imgui_internal.h
+++ b/imgui_internal.h
@@ -1284,6 +1284,7 @@
{
ImGuiInputEventType Type;
ImGuiInputSource Source;
+ ImU32 EventId; // Unique, sequential increasing integer to identify an event (if you need to correlate them to other data).
union
{
ImGuiInputEventMousePos MousePos; // if Type == ImGuiInputEventType_MousePos
@@ -1739,9 +1740,6 @@
bool Initialized;
bool FontAtlasOwnedByContext; // IO.Fonts-> is owned by the ImGuiContext and will be destructed along with it.
ImGuiIO IO;
- ImVector<ImGuiInputEvent> InputEventsQueue; // Input events which will be tricked/written into IO structure.
- ImVector<ImGuiInputEvent> InputEventsTrail; // Past input events processed in NewFrame(). This is to allow domain-specific application to access e.g mouse/pen trail.
- ImGuiMouseSource InputEventsNextMouseSource;
ImGuiStyle Style;
ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back()
float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window.
@@ -1758,6 +1756,12 @@
bool TestEngineHookItems; // Will call test engine hooks: ImGuiTestEngineHook_ItemAdd(), ImGuiTestEngineHook_ItemInfo(), ImGuiTestEngineHook_Log()
void* TestEngine; // Test engine user data
+ // Inputs
+ ImVector<ImGuiInputEvent> InputEventsQueue; // Input events which will be trickled/written into IO structure.
+ ImVector<ImGuiInputEvent> InputEventsTrail; // Past input events processed in NewFrame(). This is to allow domain-specific application to access e.g mouse/pen trail.
+ ImGuiMouseSource InputEventsNextMouseSource;
+ ImU32 InputEventsNextEventId;
+
// Windows state
ImVector<ImGuiWindow*> Windows; // Windows, sorted in display order, back to front
ImVector<ImGuiWindow*> WindowsFocusOrder; // Root windows, sorted in focus order, back to front.
@@ -2028,7 +2032,6 @@
{
IO.Ctx = this;
InputTextState.Ctx = this;
- InputEventsNextMouseSource = ImGuiMouseSource_Mouse;
Initialized = false;
FontAtlasOwnedByContext = shared_font_atlas ? false : true;
@@ -2043,6 +2046,9 @@
TestEngineHookItems = false;
TestEngine = NULL;
+ InputEventsNextMouseSource = ImGuiMouseSource_Mouse;
+ InputEventsNextEventId = 1;
+
WindowsActiveCount = 0;
CurrentWindow = NULL;
HoveredWindow = NULL;