本文整理汇总了C++中TSharedRef::GetActiveGesture方法的典型用法代码示例。如果您正苦于以下问题:C++ TSharedRef::GetActiveGesture方法的具体用法?C++ TSharedRef::GetActiveGesture怎么用?C++ TSharedRef::GetActiveGesture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TSharedRef
的用法示例。
在下文中一共展示了TSharedRef::GetActiveGesture方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateInputCommand
void FInputBindingManager::CreateInputCommand( const TSharedRef<FBindingContext>& InBindingContext, TSharedRef<FUICommandInfo> InCommandInfo )
{
check( InCommandInfo->BindingContext == InBindingContext->GetContextName() );
// The command name should be valid
check( InCommandInfo->CommandName != NAME_None );
// Should not have already created a gesture for this command
check( !InCommandInfo->ActiveGesture->IsValidGesture() );
const FName ContextName = InBindingContext->GetContextName();
FContextEntry& ContextEntry = ContextMap.FindOrAdd( ContextName );
// Our parent context must exist.
check( InBindingContext->GetContextParent() == NAME_None || ContextMap.Find( InBindingContext->GetContextParent() ) != NULL );
FCommandInfoMap& CommandInfoMap = ContextEntry.CommandInfoMap;
if( !ContextEntry.BindingContext.IsValid() )
{
ContextEntry.BindingContext = InBindingContext;
}
if( InBindingContext->GetContextParent() != NAME_None )
{
check( InBindingContext->GetContextName() != InBindingContext->GetContextParent() );
// Set a mapping from the parent of the current context to the current context
ParentToChildMap.AddUnique( InBindingContext->GetContextParent(), InBindingContext->GetContextName() );
}
if( InCommandInfo->DefaultGesture.IsValidGesture() )
{
CheckForDuplicateDefaultGestures( *InBindingContext, InCommandInfo );
}
{
TSharedPtr<FUICommandInfo> ExistingInfo = CommandInfoMap.FindRef( InCommandInfo->CommandName );
ensureMsgf( !ExistingInfo.IsValid(), TEXT("A command with name %s already exists in context %s"), *InCommandInfo->CommandName.ToString(), *InBindingContext->GetContextName().ToString() );
}
// Add the command info to the list of known infos. It can only exist once.
CommandInfoMap.Add( InCommandInfo->CommandName, InCommandInfo );
// See if there are user defined gestures for this command
FInputGesture UserDefinedGesture;
bool bFoundUserDefinedGesture = GetUserDefinedGesture( ContextName, InCommandInfo->CommandName, UserDefinedGesture );
if( !bFoundUserDefinedGesture && InCommandInfo->DefaultGesture.IsValidGesture() )
{
// Find any existing command with the same gesture
// This is for inconsistency between default and user defined gesture. We need to make sure that if default gestures are changed to a gesture that a user set to a different command, that the default gesture doesn't replace
// the existing commands gesture. Note: Duplicate default gestures are found above in CheckForDuplicateDefaultGestures
FName ExisingCommand = ContextEntry.GestureToCommandInfoMap.FindRef( InCommandInfo->DefaultGesture );
if( ExisingCommand == NAME_None )
{
// No existing command has a user defined gesture and no user defined gesture is available for this command
TSharedRef<FInputGesture> NewGesture = MakeShareable( new FInputGesture( InCommandInfo->DefaultGesture ) );
InCommandInfo->ActiveGesture = NewGesture;
}
}
else if( bFoundUserDefinedGesture )
{
// Find any existing command with the same gesture
// This is for inconsistency between default and user defined gesture. We need to make sure that if default gestures are changed to a gesture that a user set to a different command, that the default gesture doesn't replace
// the existing commands gesture.
FName ExisingCommandName = ContextEntry.GestureToCommandInfoMap.FindRef( UserDefinedGesture );
if( ExisingCommandName != NAME_None )
{
// Get the command with using the same gesture
TSharedPtr<FUICommandInfo> ExistingInfo = CommandInfoMap.FindRef( ExisingCommandName );
if( *ExistingInfo->ActiveGesture != ExistingInfo->DefaultGesture )
{
// two user defined gestures are the same within a context. If the keybinding editor was used this wont happen so this must have been directly a modified user setting file
UE_LOG(LogSlate, Error, TEXT("Duplicate user defined gestures found: [%s,%s]. Gesture for %s being removed"), *InCommandInfo->GetLabel().ToString(), *ExistingInfo->GetLabel().ToString(), *ExistingInfo->GetLabel().ToString() );
}
ContextEntry.GestureToCommandInfoMap.Remove( *ExistingInfo->ActiveGesture );
// Remove the existing gesture.
ExistingInfo->ActiveGesture = MakeShareable( new FInputGesture() );
}
TSharedRef<FInputGesture> NewGesture = MakeShareable( new FInputGesture( UserDefinedGesture ) );
// Set the active gesture on the command info
InCommandInfo->ActiveGesture = NewGesture;
}
// If the active gesture is valid, map the gesture to the map for fast lookup when processing bindings
if( InCommandInfo->ActiveGesture->IsValidGesture() )
{
checkSlow( !ContextEntry.GestureToCommandInfoMap.Contains( *InCommandInfo->GetActiveGesture() ) );
ContextEntry.GestureToCommandInfoMap.Add( *InCommandInfo->GetActiveGesture(), InCommandInfo->GetCommandName() );
}
}