示例#1
0
void FInputBindingManager::NotifyActiveGestureChanged( const FUICommandInfo& CommandInfo )
{
	FContextEntry& ContextEntry = ContextMap.FindChecked( CommandInfo.GetBindingContext() );

	// Slow but doesn't happen frequently
	for( FGestureMap::TIterator It( ContextEntry.GestureToCommandInfoMap ); It; ++It )
	{
		// Remove the currently active gesture from the map if one exists
		if( It.Value() == CommandInfo.GetCommandName() )
		{
			It.RemoveCurrent();
			// There should only be one active gesture
			break;
		}
	}

	if( CommandInfo.GetActiveGesture()->IsValidGesture() )
	{
		checkSlow( !ContextEntry.GestureToCommandInfoMap.Contains( *CommandInfo.GetActiveGesture() ) )
		ContextEntry.GestureToCommandInfoMap.Add( *CommandInfo.GetActiveGesture(), CommandInfo.GetCommandName() );
	}
	

	// The user defined gestures should have already been created
	check( UserDefinedGestures.IsValid() );

	UserDefinedGestures->SetUserDefinedGesture( CommandInfo );

	// Broadcast the gesture event when a new one is added
	OnUserDefinedGestureChanged.Broadcast(CommandInfo);
}
示例#2
0
void FUserDefinedGestures::SetUserDefinedGesture( const FUICommandInfo& CommandInfo )
{
	if( Gestures.IsValid() )
	{
		const FName BindingContext = CommandInfo.GetBindingContext();
		const FName CommandName = CommandInfo.GetCommandName();

		// Find or create the command context
		const FUserDefinedGestureKey GestureKey(BindingContext, CommandName);
		FInputGesture& UserDefinedGesture = Gestures->FindOrAdd(GestureKey);

		// Save an empty invalid gesture if one was not set
		// This is an indication that the user doesn't want this bound and not to use the default gesture
		const TSharedPtr<const FInputGesture> InputGesture = CommandInfo.GetActiveGesture();
		UserDefinedGesture = (InputGesture.IsValid()) ? *InputGesture : FInputGesture();
	}
}
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();
	}
}