void FInputBindingManager::NotifyActiveChordChanged( const FUICommandInfo& CommandInfo ) { FContextEntry& ContextEntry = ContextMap.FindChecked( CommandInfo.GetBindingContext() ); // Slow but doesn't happen frequently for( FChordMap::TIterator It( ContextEntry.ChordToCommandInfoMap ); It; ++It ) { // Remove the currently active chord from the map if one exists if( It.Value() == CommandInfo.GetCommandName() ) { It.RemoveCurrent(); // There should only be one active chord break; } } if( CommandInfo.GetActiveChord()->IsValidChord() ) { checkSlow( !ContextEntry.ChordToCommandInfoMap.Contains( *CommandInfo.GetActiveChord() ) ) ContextEntry.ChordToCommandInfoMap.Add( *CommandInfo.GetActiveChord(), CommandInfo.GetCommandName() ); } // The user defined chords should have already been created check( UserDefinedChords.IsValid() ); UserDefinedChords->SetUserDefinedChord( CommandInfo ); // Broadcast the chord event when a new one is added OnUserDefinedChordChanged.Broadcast(CommandInfo); }
void FUserDefinedChords::SetUserDefinedChord( const FUICommandInfo& CommandInfo ) { if( Chords.IsValid() ) { const FName BindingContext = CommandInfo.GetBindingContext(); const FName CommandName = CommandInfo.GetCommandName(); // Find or create the command context const FUserDefinedChordKey ChordKey(BindingContext, CommandName); FInputChord& UserDefinedChord = Chords->FindOrAdd(ChordKey); // Save an empty invalid chord if one was not set // This is an indication that the user doesn't want this bound and not to use the default chord const TSharedPtr<const FInputChord> InputChord = CommandInfo.GetActiveChord(); UserDefinedChord = (InputChord.IsValid()) ? *InputChord : FInputChord(); } }