_LockXXX flags are useful to lock keys away from code which is not input-owner aware. When using _LockXXX flags, you can use ImGuiKeyOwner_Any to lock keys from everyone. - SetKeyOwner(..., None) : clears owner - SetKeyOwner(..., Any, !Lock) : illegal (assert) - SetKeyOwner(..., Any or None, Lock) : set lock
| 9268 | // - SetKeyOwner(..., Any, !Lock) : illegal (assert) |
| 9269 | // - SetKeyOwner(..., Any or None, Lock) : set lock |
| 9270 | void ImGui::SetKeyOwner(ImGuiKey key, ImGuiID owner_id, ImGuiInputFlags flags) |
| 9271 | { |
| 9272 | IM_ASSERT(IsNamedKeyOrModKey(key) && (owner_id != ImGuiKeyOwner_Any || (flags & (ImGuiInputFlags_LockThisFrame | ImGuiInputFlags_LockUntilRelease)))); // Can only use _Any with _LockXXX flags (to eat a key away without an ID to retrieve it) |
| 9273 | IM_ASSERT((flags & ~ImGuiInputFlags_SupportedBySetKeyOwner) == 0); // Passing flags not supported by this function! |
| 9274 | |
| 9275 | ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(key); |
| 9276 | owner_data->OwnerCurr = owner_data->OwnerNext = owner_id; |
| 9277 | |
| 9278 | // We cannot lock by default as it would likely break lots of legacy code. |
| 9279 | // In the case of using LockUntilRelease while key is not down we still lock during the frame (no key_data->Down test) |
| 9280 | owner_data->LockUntilRelease = (flags & ImGuiInputFlags_LockUntilRelease) != 0; |
| 9281 | owner_data->LockThisFrame = (flags & ImGuiInputFlags_LockThisFrame) != 0 || (owner_data->LockUntilRelease); |
| 9282 | } |
| 9283 | |
| 9284 | // This is more or less equivalent to: |
| 9285 | // if (IsItemHovered() || IsItemActive()) |
nothing calls this directly
no test coverage detected