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.
| 8564 | // TestKeyOwner(..., Any) : no owner test |
| 8565 | // All paths are also testing for key not being locked, for the rare cases that key have been locked with using ImGuiInputFlags_LockXXX flags. |
| 8566 | bool ImGui::TestKeyOwner(ImGuiKey key, ImGuiID owner_id) |
| 8567 | { |
| 8568 | if (!IsNamedKeyOrModKey(key)) |
| 8569 | return true; |
| 8570 | |
| 8571 | ImGuiContext& g = *GImGui; |
| 8572 | if (g.ActiveIdUsingAllKeyboardKeys && owner_id != g.ActiveId && owner_id != ImGuiKeyOwner_Any) |
| 8573 | if (key >= ImGuiKey_Keyboard_BEGIN && key < ImGuiKey_Keyboard_END) |
| 8574 | return false; |
| 8575 | |
| 8576 | ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(key); |
| 8577 | if (owner_id == ImGuiKeyOwner_Any) |
| 8578 | return (owner_data->LockThisFrame == false); |
| 8579 | |
| 8580 | // Note: SetKeyOwner() sets OwnerCurr. It is not strictly required for most mouse routing overlap (because of ActiveId/HoveredId |
| 8581 | // are acting as filter before this has a chance to filter), but sane as soon as user tries to look into things. |
| 8582 | // Setting OwnerCurr in SetKeyOwner() is more consistent than testing OwnerNext here: would be inconsistent with getter and other functions. |
| 8583 | if (owner_data->OwnerCurr != owner_id) |
| 8584 | { |
| 8585 | if (owner_data->LockThisFrame) |
| 8586 | return false; |
| 8587 | if (owner_data->OwnerCurr != ImGuiKeyOwner_None) |
| 8588 | return false; |
| 8589 | } |
| 8590 | |
| 8591 | return true; |
| 8592 | } |
| 8593 | |
| 8594 | // _LockXXX flags are useful to lock keys away from code which is not input-owner aware. |
| 8595 | // When using _LockXXX flags, you can use ImGuiKeyOwner_Any to lock keys from everyone. |
nothing calls this directly
no test coverage detected