mirror of https://github.com/ocornut/imgui
IO: added ClearInputMouse(). made ClearInputKeys() not clear mouse data. (#4921)
Amend 6aa408c6a
This commit is contained in:
parent
21581cf70c
commit
8067d05f74
|
@ -48,6 +48,8 @@ Breaking changes:
|
|||
- ImGuiCol_TabUnfocused -> ImGuiCol_TabDimmed
|
||||
- ImGuiCol_TabUnfocusedActive -> ImGuiCol_TabDimmedSelected
|
||||
Kept inline redirecting enums (will obsolete).
|
||||
- IO: io.ClearInputKeys() (first exposed in 1.89.8) doesn't clear mouse data.
|
||||
Newly added io.ClearInputMouse() does. (#4921)
|
||||
- Drag and Drop: renamed ImGuiDragDropFlags_SourceAutoExpirePayload to
|
||||
ImGuiDragDropFlags_PayloadAutoExpire. Kept inline redirecting enum (will obsolete). (#1725, #143).
|
||||
|
||||
|
@ -59,6 +61,7 @@ Other changes:
|
|||
shape change as honored by backends. Keeping this enabling will hopefully increase pressure
|
||||
on third-party backends to set ImGuiBackendFlags_HasMouseCursors and honor changes of
|
||||
ImGui::GetMouseCursor() value. (#1495)
|
||||
- IO: Added io.ClearInputMouse() to clear mouse state. (#4921)
|
||||
- TabBar, Style: added ImGuiTabBarFlags_DrawSelectedOverline option to draw an horizontal
|
||||
line over selected tabs to increase visibility. This is used by docking.
|
||||
Added corresponding ImGuiCol_TabSelectedOverline and ImGuiCol_TabDimmedSelectedOverline colors.
|
||||
|
@ -842,7 +845,7 @@ Breaking changes:
|
|||
|
||||
- IO: Obsoleted io.ClearInputCharacters() (added in 1.47) as it now ambiguous
|
||||
and often incorrect/misleading considering the existence of a higher-level
|
||||
input queue. This is automatically cleared by io.ClearInputsKeys(). (#4921)
|
||||
input queue. This is automatically cleared by io.ClearInputKeys(). (#4921)
|
||||
- ImDrawData: CmdLists[] array is now owned, changed from 'ImDrawList**' to
|
||||
'ImVector<ImDrawList*>'. Majority of users shouldn't be affected, but you
|
||||
cannot compare to NULL nor reassign manually anymore.
|
||||
|
@ -880,10 +883,10 @@ Other changes:
|
|||
will slightly reduce scrollbar size. Generally we tried to make it that window
|
||||
border size has no incidence on layout but this can't work with thick borders. (#2522)
|
||||
- IO: Added io.ClearEventsQueue() to clear incoming inputs events. (#4921)
|
||||
May be useful in conjunction with io.ClearInputsKeys() if you need to clear
|
||||
May be useful in conjunction with io.ClearInputKeys() if you need to clear
|
||||
both current inputs state and queued events (e.g. when using blocking native
|
||||
dialogs such as Windows's ::MessageBox() or ::GetOpenFileName()).
|
||||
- IO: Changed io.ClearInputsKeys() specs to also clear current frame character buffer
|
||||
- IO: Changed io.ClearInputKeys() specs to also clear current frame character buffer
|
||||
(what now obsoleted io.ClearInputCharacters() did), as this is effectively the
|
||||
desirable behavior.
|
||||
- Misc: Added IMGUI_DISABLE_STB_SPRINTF_IMPLEMENTATION config macro to disable
|
||||
|
|
21
imgui.cpp
21
imgui.cpp
|
@ -430,6 +430,7 @@ CODE
|
|||
When you are not sure about an old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files.
|
||||
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
|
||||
|
||||
- 2024/06/21 (1.90.9) - io: ClearInputKeys() (first exposed in 1.89.8) doesn't clear mouse data, newly added ClearInputMouse() does.
|
||||
- 2024/06/20 (1.90.9) - renamed ImGuiDragDropFlags_SourceAutoExpirePayload to ImGuiDragDropFlags_PayloadAutoExpire.
|
||||
- 2024/06/18 (1.90.9) - style: renamed ImGuiCol_TabActive -> ImGuiCol_TabSelected, ImGuiCol_TabUnfocused -> ImGuiCol_TabDimmed, ImGuiCol_TabUnfocusedActive -> ImGuiCol_TabDimmedSelected.
|
||||
- 2024/06/10 (1.90.9) - removed old nested structure: renaming ImGuiStorage::ImGuiStoragePair type to ImGuiStoragePair (simpler for many languages).
|
||||
|
@ -1453,7 +1454,7 @@ void ImGuiIO::ClearEventsQueue()
|
|||
g.InputEventsQueue.clear();
|
||||
}
|
||||
|
||||
// Clear current keyboard/mouse/gamepad state + current frame text input buffer. Equivalent to releasing all keys/buttons.
|
||||
// Clear current keyboard/gamepad state + current frame text input buffer. Equivalent to releasing all keys/buttons.
|
||||
void ImGuiIO::ClearInputKeys()
|
||||
{
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
|
||||
|
@ -1461,12 +1462,26 @@ void ImGuiIO::ClearInputKeys()
|
|||
#endif
|
||||
for (int n = 0; n < IM_ARRAYSIZE(KeysData); n++)
|
||||
{
|
||||
if (ImGui::IsMouseKey((ImGuiKey)(n + ImGuiKey_KeysData_OFFSET)))
|
||||
continue;
|
||||
KeysData[n].Down = false;
|
||||
KeysData[n].DownDuration = -1.0f;
|
||||
KeysData[n].DownDurationPrev = -1.0f;
|
||||
}
|
||||
KeyCtrl = KeyShift = KeyAlt = KeySuper = false;
|
||||
KeyMods = ImGuiMod_None;
|
||||
InputQueueCharacters.resize(0); // Behavior of old ClearInputCharacters().
|
||||
}
|
||||
|
||||
void ImGuiIO::ClearInputMouse()
|
||||
{
|
||||
for (ImGuiKey key = ImGuiKey_Mouse_BEGIN; key < ImGuiKey_Mouse_END; key = (ImGuiKey)(key + 1))
|
||||
{
|
||||
ImGuiKeyData* key_data = &KeysData[key - ImGuiKey_KeysData_OFFSET];
|
||||
key_data->Down = false;
|
||||
key_data->DownDuration = -1.0f;
|
||||
key_data->DownDurationPrev = -1.0f;
|
||||
}
|
||||
MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
|
||||
for (int n = 0; n < IM_ARRAYSIZE(MouseDown); n++)
|
||||
{
|
||||
|
@ -1474,7 +1489,6 @@ void ImGuiIO::ClearInputKeys()
|
|||
MouseDownDuration[n] = MouseDownDurationPrev[n] = -1.0f;
|
||||
}
|
||||
MouseWheel = MouseWheelH = 0.0f;
|
||||
InputQueueCharacters.resize(0); // Behavior of old ClearInputCharacters().
|
||||
}
|
||||
|
||||
// Removed this as it is ambiguous/misleading and generally incorrect to use with the existence of a higher-level input queue.
|
||||
|
@ -9632,7 +9646,10 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
|
|||
// - we clear in EndFrame() and not now in order allow application/user code polling this flag
|
||||
// (e.g. custom backend may want to clear additional data, custom widgets may want to react with a "canceling" event).
|
||||
if (g.IO.AppFocusLost)
|
||||
{
|
||||
g.IO.ClearInputKeys();
|
||||
g.IO.ClearInputMouse();
|
||||
}
|
||||
}
|
||||
|
||||
ImGuiID ImGui::GetKeyOwner(ImGuiKey key)
|
||||
|
|
9
imgui.h
9
imgui.h
|
@ -28,7 +28,7 @@
|
|||
// Library Version
|
||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
||||
#define IMGUI_VERSION "1.90.9 WIP"
|
||||
#define IMGUI_VERSION_NUM 19082
|
||||
#define IMGUI_VERSION_NUM 19083
|
||||
#define IMGUI_HAS_TABLE
|
||||
|
||||
/*
|
||||
|
@ -1535,7 +1535,7 @@ enum ImGuiConfigFlags_
|
|||
ImGuiConfigFlags_NavEnableGamepad = 1 << 1, // Master gamepad navigation enable flag. Backend also needs to set ImGuiBackendFlags_HasGamepad.
|
||||
ImGuiConfigFlags_NavEnableSetMousePos = 1 << 2, // Instruct navigation to move the mouse cursor. May be useful on TV/console systems where moving a virtual mouse is awkward. Will update io.MousePos and set io.WantSetMousePos=true. If enabled you MUST honor io.WantSetMousePos requests in your backend, otherwise ImGui will react as if the mouse is jumping around back and forth.
|
||||
ImGuiConfigFlags_NavNoCaptureKeyboard = 1 << 3, // Instruct navigation to not set the io.WantCaptureKeyboard flag when io.NavActive is set.
|
||||
ImGuiConfigFlags_NoMouse = 1 << 4, // Instruct imgui to clear mouse position/buttons in NewFrame(). This allows ignoring the mouse information set by the backend.
|
||||
ImGuiConfigFlags_NoMouse = 1 << 4, // Instruct dear imgui to disable mouse interactions.
|
||||
ImGuiConfigFlags_NoMouseCursorChange = 1 << 5, // Instruct backend to not alter mouse cursor shape and visibility. Use if the backend cursor changes are interfering with yours and you don't want to use SetMouseCursor() to change mouse cursor. You may want to honor requests from imgui by reading GetMouseCursor() yourself instead.
|
||||
|
||||
// User storage (to allow your backend/engine to communicate to code that may be shared between multiple projects. Those flags are NOT used by core Dear ImGui)
|
||||
|
@ -2198,7 +2198,7 @@ struct ImGuiIO
|
|||
// Option to deactivate io.AddFocusEvent(false) handling.
|
||||
// - May facilitate interactions with a debugger when focus loss leads to clearing inputs data.
|
||||
// - Backends may have other side-effects on focus loss, so this will reduce side-effects but not necessary remove all of them.
|
||||
bool ConfigDebugIgnoreFocusLoss; // = false // Ignore io.AddFocusEvent(false), consequently not calling io.ClearInputKeys() in input processing.
|
||||
bool ConfigDebugIgnoreFocusLoss; // = false // Ignore io.AddFocusEvent(false), consequently not calling io.ClearInputKeys()/io.ClearInputMouse() in input processing.
|
||||
|
||||
// Options to audit .ini data
|
||||
bool ConfigDebugIniSettings; // = false // Save .ini data with extra comments (particularly helpful for Docking, but makes saving slower)
|
||||
|
@ -2247,7 +2247,8 @@ struct ImGuiIO
|
|||
IMGUI_API void SetKeyEventNativeData(ImGuiKey key, int native_keycode, int native_scancode, int native_legacy_index = -1); // [Optional] Specify index for legacy <1.87 IsKeyXXX() functions with native indices + specify native keycode, scancode.
|
||||
IMGUI_API void SetAppAcceptingEvents(bool accepting_events); // 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.
|
||||
IMGUI_API void ClearEventsQueue(); // Clear all incoming events.
|
||||
IMGUI_API void ClearInputKeys(); // Clear current keyboard/mouse/gamepad state + current frame text input buffer. Equivalent to releasing all keys/buttons.
|
||||
IMGUI_API void ClearInputKeys(); // Clear current keyboard/gamepad state + current frame text input buffer. Equivalent to releasing all keys/buttons.
|
||||
IMGUI_API void ClearInputMouse(); // Clear current mouse state.
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
IMGUI_API void ClearInputCharacters(); // [Obsoleted in 1.89.8] Clear the current frame text input buffer. Now included within ClearInputKeys().
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue