TestKeyOwner(..., ID) : (owner == None || owner == ID) TestKeyOwner(..., None) : (owner == None) TestKeyOwner(..., Any) : no owner test All paths are also testing for key not being locked, for the rare cases that key have been locked with using ImGuiInputFlags_LockXXX flags.
| 10404 | // TestKeyOwner(..., Any) : no owner test |
| 10405 | // All paths are also testing for key not being locked, for the rare cases that key have been locked with using ImGuiInputFlags_LockXXX flags. |
| 10406 | bool ImGui::TestKeyOwner(ImGuiKey key, ImGuiID owner_id) |
| 10407 | { |
| 10408 | if (!IsNamedKeyOrMod(key)) |
| 10409 | return true; |
| 10410 | |
| 10411 | ImGuiContext& g = *GImGui; |
| 10412 | if (g.ActiveIdUsingAllKeyboardKeys && owner_id != g.ActiveId && owner_id != ImGuiKeyOwner_Any) |
| 10413 | if (key >= ImGuiKey_Keyboard_BEGIN && key < ImGuiKey_Keyboard_END) |
| 10414 | return false; |
| 10415 | |
| 10416 | ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(&g, key); |
| 10417 | if (owner_id == ImGuiKeyOwner_Any) |
| 10418 | return (owner_data->LockThisFrame == false); |
| 10419 | |
| 10420 | // Note: SetKeyOwner() sets OwnerCurr. It is not strictly required for most mouse routing overlap (because of ActiveId/HoveredId |
| 10421 | // are acting as filter before this has a chance to filter), but sane as soon as user tries to look into things. |
| 10422 | // Setting OwnerCurr in SetKeyOwner() is more consistent than testing OwnerNext here: would be inconsistent with getter and other functions. |
| 10423 | if (owner_data->OwnerCurr != owner_id) |
| 10424 | { |
| 10425 | if (owner_data->LockThisFrame) |
| 10426 | return false; |
| 10427 | if (owner_data->OwnerCurr != ImGuiKeyOwner_NoOwner) |
| 10428 | return false; |
| 10429 | } |
| 10430 | |
| 10431 | return true; |
| 10432 | } |
| 10433 | |
| 10434 | // _LockXXX flags are useful to lock keys away from code which is not input-owner aware. |
| 10435 | // When using _LockXXX flags, you can use ImGuiKeyOwner_Any to lock keys from everyone. |
nothing calls this directly
no test coverage detected