@@ -8370,17 +8370,9 @@ bool ImGui::TestKeyOwner(ImGuiKey key, ImGuiID owner_id)
8370
8370
if (owner_id == ImGuiKeyOwner_Any)
8371
8371
return (owner_data->LockThisFrame == false);
8372
8372
8373
- // FIXME: For consistency with routing may be good to disable that, OR we could differentiate preemptive routing from setting owner on click.
8374
- // For now it is better to disable so we can actually get report of case where this may matter.
8375
- // -> Better to move in the SetKeyOwner() call, aka have a flag to set ->OwnerCurr in SetKeyOwner() ?
8376
- // May simply be inconsistent and unneeded to offer that feature:
8377
- // - for typical keyboard/gamepad routing with multiple claims and ServeLast, we don't want to affect owner testing during the frame.
8378
- // - for typical mouse routing overlap + hovered window generally prevents making it useful to alter owner testing during the frame.
8379
- // - but effectively Locked flag can alter same-frame behavior.
8380
- //// We want OwnerNext to be handled immediately so SetKeyOwner(key, id1), TestKeyOwner(key, id2) == false
8381
- //if (owner_data->OwnerNext != ImGuiKeyOwner_None && owner_data->OwnerNext != owner)
8382
- // return false;
8383
-
8373
+ // Note: SetKeyOwner() sets OwnerCurr. It is not strictly required for most mouse routing overlap (because of ActiveId/HoveredId
8374
+ // are acting as filter before this has a chance to filter), but sane as soon as user tries to look into things.
8375
+ // Setting OwnerCurr in SetKeyOwner() is more consistent than testing OwnerNext here: would be inconsistent with getter and other functions.
8384
8376
if (owner_data->OwnerCurr != owner_id)
8385
8377
{
8386
8378
if (owner_data->LockThisFrame)
@@ -8392,6 +8384,7 @@ bool ImGui::TestKeyOwner(ImGuiKey key, ImGuiID owner_id)
8392
8384
return true;
8393
8385
}
8394
8386
8387
+ // _LockXXX flags are useful to lock keys away from code which is not input-owner aware.
8395
8388
// When using _LockXXX flags, you can use ImGuiKeyOwner_Any to lock keys from everyone.
8396
8389
// - SetKeyOwner(..., None) : clears owner
8397
8390
// - SetKeyOwner(..., Any, !Lock) : illegal (assert)
@@ -8401,14 +8394,12 @@ void ImGui::SetKeyOwner(ImGuiKey key, ImGuiID owner_id, ImGuiInputFlags flags)
8401
8394
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)
8402
8395
8403
8396
ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(key);
8404
- owner_data->OwnerNext = owner_id;
8397
+ owner_data->OwnerCurr = owner_data-> OwnerNext = owner_id;
8405
8398
8406
8399
// We cannot lock by default as it would likely break lots of legacy code.
8407
8400
// In the case of using LockUntilRelease while key is not down we still lock during the frame (no key_data->Down test)
8408
8401
owner_data->LockUntilRelease = (flags & ImGuiInputFlags_LockUntilRelease) != 0;
8409
8402
owner_data->LockThisFrame = (flags & ImGuiInputFlags_LockThisFrame) != 0 || (owner_data->LockUntilRelease);
8410
- if (owner_data->LockThisFrame)
8411
- owner_data->OwnerCurr = owner_id;
8412
8403
}
8413
8404
8414
8405
// This is more or less equivalent to:
0 commit comments