@ -8406,8 +8406,6 @@ static bool IsKeyChordPotentiallyCharInput(ImGuiKeyChord key_chord)
// - Routes and key ownership are attributed at the beginning of next frame based on best score and mod state.
// (Conceptually this does a "Submit for next frame" + "Test for current frame".
// As such, it could be called TrySetXXX or SubmitXXX, or the Submit and Test operations should be separate.)
// - Using 'owner_id == ImGuiKeyOwner_Any/0': auto-assign an owner based on current focus scope (each window has its focus scope by default)
// - Using 'owner_id == ImGuiKeyOwner_None': allows disabling/locking a shortcut.
bool ImGui : : SetShortcutRouting ( ImGuiKeyChord key_chord , ImGuiID owner_id , ImGuiInputFlags flags )
{
ImGuiContext & g = * GImGui ;
@ -8415,6 +8413,8 @@ bool ImGui::SetShortcutRouting(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiI
flags | = ImGuiInputFlags_RouteGlobalHigh ; // IMPORTANT: This is the default for SetShortcutRouting() but NOT Shortcut()
else
IM_ASSERT ( ImIsPowerOfTwo ( flags & ImGuiInputFlags_RouteMask_ ) ) ; // Check that only 1 routing flag is used
IM_ASSERT ( owner_id ! = ImGuiKeyOwner_Any & & owner_id ! = ImGuiKeyOwner_None ) ;
if ( key_chord & ImGuiMod_Shortcut )
key_chord = ConvertShortcutMod ( key_chord ) ;
@ -8454,18 +8454,17 @@ bool ImGui::SetShortcutRouting(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiI
// Submit routing for NEXT frame (assuming score is sufficient)
// FIXME: Could expose a way to use a "serve last" policy for same score resolution (using <= instead of <).
ImGuiKeyRoutingData * routing_data = GetShortcutRoutingData ( key_chord ) ;
const ImGuiID routing_id = GetRoutingIdFromOwnerId ( owner_id ) ;
//const bool set_route = (flags & ImGuiInputFlags_ServeLast) ? (score <= routing_data->RoutingNextScore) : (score < routing_data->RoutingNextScore);
if ( score < routing_data - > RoutingNextScore )
{
routing_data - > RoutingNext = routing _id;
routing_data - > RoutingNext = owner _id;
routing_data - > RoutingNextScore = ( ImU8 ) score ;
}
// Return routing state for CURRENT frame
if ( routing_data - > RoutingCurr = = routing _id)
if ( routing_data - > RoutingCurr = = owner _id)
IMGUI_DEBUG_LOG_INPUTROUTING ( " --> granting current route \n " ) ;
return routing_data - > RoutingCurr = = routing _id;
return routing_data - > RoutingCurr = = owner _id;
}
// Currently unused by core (but used by tests)
@ -9428,6 +9427,13 @@ bool ImGui::Shortcut(ImGuiKeyChord key_chord, ImGuiID owner_id, ImGuiInputFlags
// When using (owner_id == 0/Any): SetShortcutRouting() will use CurrentFocusScopeId and filter with this, so IsKeyPressed() is fine with he 0/Any.
if ( ( flags & ImGuiInputFlags_RouteMask_ ) = = 0 )
flags | = ImGuiInputFlags_RouteFocused ;
// Using 'owner_id == ImGuiKeyOwner_Any/0': auto-assign an owner based on current focus scope (each window has its focus scope by default)
// Effectively makes Shortcut() always input-owner aware.
if ( owner_id = = ImGuiKeyOwner_Any | | owner_id = = ImGuiKeyOwner_None )
owner_id = GetRoutingIdFromOwnerId ( owner_id ) ;
// Submit route
if ( ! SetShortcutRouting ( key_chord , owner_id , flags ) )
return false ;