You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/FAQ.md
+6-2Lines changed: 6 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -96,9 +96,13 @@ e.g. `if (ImGui::GetIO().WantCaptureMouse) { ... }`
96
96
**Note:** You should always pass your mouse/keyboard inputs to Dear ImGui, even when the io.WantCaptureXXX flag are set false.
97
97
This is because imgui needs to detect that you clicked in the void to unfocus its own windows.
98
98
99
-
**Note:** The `io.WantCaptureMouse` is more accurate that any manual attempt to "check if the mouse is hovering a window" (don't do that!). It handle mouse dragging correctly (both dragging that started over your application or over an imgui window) and handle e.g. modal windows blocking inputs. Those flags are updated by `ImGui::NewFrame()`. Preferably read the flags after calling NewFrame() if you can afford it, but reading them before is also perfectly fine, as the bool toggle fairly rarely. If you have on a touch device, you might find use for an early call to `UpdateHoveredWindowAndCaptureFlags()`.
99
+
**Note:** The `io.WantCaptureMouse` is more correct that any manual attempt to "check if the mouse is hovering a window" (don't do that!). It handle mouse dragging correctly (both dragging that started over your application or over a Dear ImGui window) and handle e.g. popup and modal windows blocking inputs.
100
100
101
-
**Note:** Text input widget releases focus on "Return KeyDown", so the subsequent "Return KeyUp" event that your application receive will typically have `io.WantCaptureKeyboard == false`. Depending on your application logic it may or not be inconvenient. You might want to track which key-downs were targeted for Dear ImGui, e.g. with an array of bool, and filter out the corresponding key-ups.)
101
+
**Note:** Those flags are updated by `ImGui::NewFrame()`. However it is generally more correct and easier that you poll flags from the previous frame, then submit your inputs, then call `NewFrame()`. If you attempt to do the opposite (which is generally harder) you are likely going to submit your inputs after `NewFrame()`, and therefore too late.
102
+
103
+
**Note:** If you are using a touch device, you may find use for an early call to `UpdateHoveredWindowAndCaptureFlags()` to correctly dispatch your initial touch. We will work on better out-of-the-box touch support in the future.
104
+
105
+
**Note:** Text input widget releases focus on the "KeyDown" event of the Return key, so the subsequent "KeyUp" event that your application receive will typically have `io.WantCaptureKeyboard == false`. Depending on your application logic it may or not be inconvenient to receive that KeyUp event. You might want to track which key-downs were targeted for Dear ImGui, e.g. with an array of bool, and filter out the corresponding key-ups.)
- Run and study the examples and demo in imgui_demo.cpp to get acquainted with the library.
@@ -177,9 +179,11 @@ CODE
177
179
- Refer to the bindings and demo applications in the examples/ folder for instruction on how to setup your code.
178
180
- If you are running over a standard OS with a common graphics API, you should be able to use unmodified imgui_impl_*** files from the examples/ folder.
179
181
182
+
180
183
HOW A SIMPLE APPLICATION MAY LOOK LIKE
181
184
--------------------------------------
182
-
EXHIBIT 1: USING THE EXAMPLE BINDINGS (imgui_impl_XXX.cpp files from the examples/ folder).
185
+
EXHIBIT 1: USING THE EXAMPLE BINDINGS (= imgui_impl_XXX.cpp files from the examples/ folder).
186
+
The sub-folders in examples/ contains examples applications following this structure.
183
187
184
188
// Application init: create a dear imgui context, setup some options, load fonts
185
189
ImGui::CreateContext();
@@ -268,8 +272,15 @@ CODE
268
272
// Shutdown
269
273
ImGui::DestroyContext();
270
274
275
+
To decide whether to dispatch mouse/keyboard inputs to Dear ImGui to the rest your application,
276
+
you should read the 'io.WantCaptureMouse', 'io.WantCaptureKeyboard' and 'io.WantTextInput' flags!
277
+
Please read the FAQ and example applications for details about this!
278
+
279
+
271
280
HOW A SIMPLE RENDERING FUNCTION MAY LOOK LIKE
272
281
---------------------------------------------
282
+
The bindings in impl_impl_XXX.cpp files contains many working implementations of a rendering function.
Copy file name to clipboardExpand all lines: imgui.h
+14-12Lines changed: 14 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -910,12 +910,12 @@ enum ImGuiFocusedFlags_
910
910
ImGuiFocusedFlags_None = 0,
911
911
ImGuiFocusedFlags_ChildWindows = 1 << 0, // IsWindowFocused(): Return true if any children of the window is focused
912
912
ImGuiFocusedFlags_RootWindow = 1 << 1, // IsWindowFocused(): Test from root window (top most parent of the current hierarchy)
913
-
ImGuiFocusedFlags_AnyWindow = 1 << 2, // IsWindowFocused(): Return true if any window is focused. Important: If you are trying to tell how to dispatch your low-level inputs, do NOT use this. Use ImGui::GetIO().WantCaptureMouse instead.
913
+
ImGuiFocusedFlags_AnyWindow = 1 << 2, // IsWindowFocused(): Return true if any window is focused. Important: If you are trying to tell how to dispatch your low-level inputs, do NOT use this. Use 'io.WantCaptureMouse' instead! Please read the FAQ!
// Flags for ImGui::IsItemHovered(), ImGui::IsWindowHovered()
918
-
// Note: if you are trying to check whether your mouse should be dispatched to imgui or to your app, you should use the 'io.WantCaptureMouse' boolean for that. Please read the FAQ!
918
+
// Note: if you are trying to check whether your mouse should be dispatched to Dear ImGui or to your app, you should use 'io.WantCaptureMouse' instead! Please read the FAQ!
919
919
// Note: windows with the ImGuiWindowFlags_NoInputs flag are ignored by IsWindowHovered() calls.
920
920
enum ImGuiHoveredFlags_
921
921
{
@@ -1019,7 +1019,7 @@ enum ImGuiKeyModFlags_
1019
1019
ImGuiKeyModFlags_Super = 1 << 3
1020
1020
};
1021
1021
1022
-
// Gamepad/Keyboard directional navigation
1022
+
// Gamepad/Keyboard navigation
1023
1023
// Keyboard: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.KeysDown[] + io.KeyMap[] arrays.
1024
1024
// Gamepad: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable. Back-end: set ImGuiBackendFlags_HasGamepad and fill the io.NavInputs[] fields before calling NewFrame(). Note that io.NavInputs[] is cleared by EndFrame().
1025
1025
// Read instructions in imgui.cpp for more details. Download PNG/PSD at http://goo.gl/9LgVZW.
@@ -1500,17 +1500,19 @@ struct ImGuiIO
1500
1500
IMGUI_API voidClearInputCharacters(); // Clear the text input buffer manually
bool WantCaptureMouse; //When io.WantCaptureMouse is true, imgui will use the mouse inputs, do not dispatch them to your main game/application (in both cases, always pass on mouse inputs to imgui). (e.g. unclicked mouse is hovering over an imgui window, widget is active, mouse was clicked over an imgui window, etc.).
1507
-
bool WantCaptureKeyboard; //When io.WantCaptureKeyboard is true, imgui will use the keyboard inputs, do not dispatch them to your main game/application (in both cases, always pass keyboard inputs to imgui). (e.g. InputText active, or an imgui window is focused and navigation is enabled, etc.).
1508
-
bool WantTextInput; // Mobile/console: when io.WantTextInput is true, you may display an on-screen keyboard. This is set by ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active).
1509
-
bool WantSetMousePos; // MousePos has been altered, back-end should reposition mouse on next frame. Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled.
1510
-
bool WantSaveIniSettings; // When manual .ini load/save is active (io.IniFilename == NULL), this will be set to notify your application that you can call SaveIniSettingsToMemory() and save yourself. IMPORTANT: You need to clear io.WantSaveIniSettings yourself.
1511
-
bool NavActive; //Directional navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag.
1512
-
bool NavVisible; //Directional navigation is visible and allowed (will handle ImGuiKey_NavXXX events).
1513
-
float Framerate; // Application framerate estimation, in frame per second. Solely for convenience. Rolling average estimation based on IO.DeltaTime over 120 frames
1508
+
bool WantCaptureMouse; //Set when Dear ImGui will use mouse inputs, in this case do not dispatch them to your main game/application (either way, always pass on mouse inputs to imgui). (e.g. unclicked mouse is hovering over an imgui window, widget is active, mouse was clicked over an imgui window, etc.).
1509
+
bool WantCaptureKeyboard; //Set when Dear ImGui will use keyboard inputs, in this case do not dispatch them to your main game/application (either way, always pass keyboard inputs to imgui). (e.g. InputText active, or an imgui window is focused and navigation is enabled, etc.).
1510
+
bool WantTextInput; // Mobile/console: when set, you may display an on-screen keyboard. This is set by Dear ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active).
1511
+
bool WantSetMousePos; // MousePos has been altered, back-end should reposition mouse on next frame. Rarely used! Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled.
1512
+
bool WantSaveIniSettings; // When manual .ini load/save is active (io.IniFilename == NULL), this will be set to notify your application that you can call SaveIniSettingsToMemory() and save yourself. Important: clear io.WantSaveIniSettings yourself after saving!
1513
+
bool NavActive; //Keyboard/Gamepad navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag.
1514
+
bool NavVisible; //Keyboard/Gamepad navigation is visible and allowed (will handle ImGuiKey_NavXXX events).
1515
+
float Framerate; // Application framerate estimate, in frame per second. Solely for convenience. Rolling average estimation based on io.DeltaTime over 120 frames.
1514
1516
int MetricsRenderVertices; // Vertices output during last call to Render()
1515
1517
int MetricsRenderIndices; // Indices output during last call to Render() = number of triangles * 3
1516
1518
int MetricsRenderWindows; // Number of visible windows
Copy file name to clipboardExpand all lines: imgui_internal.h
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -86,7 +86,7 @@ struct ImGuiGroupData; // Stacked storage data for BeginGroup()/End
86
86
structImGuiInputTextState; // Internal state of the currently focused/edited text input box
87
87
structImGuiItemHoveredDataBackup; // Backup and restore IsItemHovered() internal data
88
88
structImGuiMenuColumns; // Simple column measurement, currently used for MenuItem() only
89
-
structImGuiNavMoveResult; // Result of a directional navigation move query result
89
+
structImGuiNavMoveResult; // Result of a gamepad/keyboard directional navigation move query result
90
90
structImGuiNextWindowData; // Storage for SetNextWindow** functions
91
91
structImGuiNextItemData; // Storage for SetNextItem** functions
92
92
structImGuiPopupData; // Storage for current popup stack
@@ -1062,7 +1062,7 @@ struct ImGuiContext
1062
1062
bool ActiveIdHasBeenPressedBefore; // Track whether the active id led to a press (this is to allow changing between PressOnClick and PressOnRelease without pressing twice). Used by range_select branch.
1063
1063
bool ActiveIdHasBeenEditedBefore; // Was the value associated to the widget Edited over the course of the Active state.
1064
1064
bool ActiveIdHasBeenEditedThisFrame;
1065
-
ImU32 ActiveIdUsingNavDirMask; // Active widget will want to read those directional navigation requests (e.g. can activate a button and move away from it)
1065
+
ImU32 ActiveIdUsingNavDirMask; // Active widget will want to read those nav move requests (e.g. can activate a button and move away from it)
1066
1066
ImU32 ActiveIdUsingNavInputMask; // Active widget will want to read those nav inputs.
1067
1067
ImU64 ActiveIdUsingKeyInputMask; // Active widget will want to read those key inputs. When we grow the ImGuiKey enum we'll need to either to order the enum to make useful keys come first, either redesign this into e.g. a small array.
1068
1068
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
0 commit comments