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.
| 9235 | // TestKeyOwner(..., Any) : no owner test |
| 9236 | // All paths are also testing for key not being locked, for the rare cases that key have been locked with using ImGuiInputFlags_LockXXX flags. |
| 9237 | bool ImGui::TestKeyOwner(ImGuiKey key, ImGuiID owner_id) |
| 9238 | { |
| 9239 | if (!IsNamedKeyOrModKey(key)) |
| 9240 | return true; |
| 9241 | |
| 9242 | ImGuiContext& g = *GImGui; |
| 9243 | if (g.ActiveIdUsingAllKeyboardKeys && owner_id != g.ActiveId && owner_id != ImGuiKeyOwner_Any) |
| 9244 | if (key >= ImGuiKey_Keyboard_BEGIN && key < ImGuiKey_Keyboard_END) |
| 9245 | return false; |
| 9246 | |
| 9247 | ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(key); |
| 9248 | if (owner_id == ImGuiKeyOwner_Any) |
| 9249 | return (owner_data->LockThisFrame == false); |
| 9250 | |
| 9251 | // Note: SetKeyOwner() sets OwnerCurr. It is not strictly required for most mouse routing overlap (because of ActiveId/HoveredId |
| 9252 | // are acting as filter before this has a chance to filter), but sane as soon as user tries to look into things. |
| 9253 | // Setting OwnerCurr in SetKeyOwner() is more consistent than testing OwnerNext here: would be inconsistent with getter and other functions. |
| 9254 | if (owner_data->OwnerCurr != owner_id) |
| 9255 | { |
| 9256 | if (owner_data->LockThisFrame) |
| 9257 | return false; |
| 9258 | if (owner_data->OwnerCurr != ImGuiKeyOwner_None) |
| 9259 | return false; |
| 9260 | } |
| 9261 | |
| 9262 | return true; |
| 9263 | } |
| 9264 | |
| 9265 | // _LockXXX flags are useful to lock keys away from code which is not input-owner aware. |
| 9266 | // When using _LockXXX flags, you can use ImGuiKeyOwner_Any to lock keys from everyone. |
nothing calls this directly
no test coverage detected