当前位置: 首页>>代码示例>>C++>>正文


C++ TSharedRef::BackspaceChar方法代码示例

本文整理汇总了C++中TSharedRef::BackspaceChar方法的典型用法代码示例。如果您正苦于以下问题:C++ TSharedRef::BackspaceChar方法的具体用法?C++ TSharedRef::BackspaceChar怎么用?C++ TSharedRef::BackspaceChar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TSharedRef的用法示例。


在下文中一共展示了TSharedRef::BackspaceChar方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnKeyChar

FReply FTextEditHelper::OnKeyChar( const FCharacterEvent& InCharacterEvent, const TSharedRef< ITextEditorWidget >& TextEditor )
{
	FReply Reply = FReply::Unhandled();

	// Check for special characters
	const TCHAR Character = InCharacterEvent.GetCharacter();

	switch( Character )
	{
		// Backspace
	case TCHAR( 8 ):
		{
			if( !TextEditor->GetIsReadOnly() )
			{
				FScopedTextTransaction TextTransaction(TextEditor);

				TextEditor->BackspaceChar();
				
				Reply = FReply::Handled();
			}
		}
		break;


		// Tab
	case TCHAR( '\t' ):
		{
			Reply = FReply::Handled();
		}
		break;


		// Newline (Ctrl+Enter), we handle adding new lines via SMultiLineEditableText::OnEnter rather than processing \n characters
	case TCHAR( '\n' ):
		{
			Reply = FReply::Handled();
		}
		break;


		// Swallow OnKeyChar keys that we don't want to be entered into the buffer
	case 1:		// Swallow Ctrl+A, we handle that through OnKeyDown
	case 3:		// Swallow Ctrl+C, we handle that through OnKeyDown
	case 13:	// Swallow Enter, we handle that through OnKeyDown
	case 22:	// Swallow Ctrl+V, we handle that through OnKeyDown
	case 24:	// Swallow Ctrl+X, we handle that through OnKeyDown
	case 25:	// Swallow Ctrl+Y, we handle that through OnKeyDown
	case 26:	// Swallow Ctrl+Z, we handle that through OnKeyDown
	case 27:	// Swallow ESC, we handle that through OnKeyDown
	case 127:	// Swallow CTRL+Backspace, we handle that through OnKeyDown
		Reply = FReply::Handled();
		break;


		// Any other character!
	default:
		{
			// Type the character, but only if it is allowed.
			if (!TextEditor->GetIsReadOnly() && TextEditor->CanTypeCharacter(Character))
			{
				FScopedTextTransaction TextTransaction(TextEditor);
				TextEditor->TypeChar( Character );
				Reply = FReply::Handled();
			}
			else
			{
				Reply = FReply::Unhandled();
			}
		}
		break;

	}


	return Reply;
}
开发者ID:xiangyuan,项目名称:Unreal4,代码行数:76,代码来源:TextEditHelper.cpp

示例2: OnKeyDown


//.........这里部分代码省略.........
				FIntPoint(+1, 0),
				// selects text.	
				ECursorAction::SelectText
			));
		}

		FScopedTextTransaction TextTransaction(TextEditor);

		// Delete selected text
		TextEditor->DeleteChar();
		
		return FReply::Handled();
	}	
	else if( Key == EKeys::Escape )
	{
		return TextEditor->OnEscape();
	}

	// @Todo: Slate keybindings support more than one set of keys. 
	//Alternate key for cut (Shift+Delete)
	else if( Key == EKeys::Delete && InKeyEvent.IsShiftDown() && TextEditor->CanExecuteCut() )
	{
		// Cut text to clipboard
		TextEditor->CutSelectedTextToClipboard();
		
		return FReply::Handled();
	}

	// @Todo: Slate keybindings support more than one set of keys. 
	// Alternate key for copy (Ctrl+Insert) 
	else if( Key == EKeys::Insert && InKeyEvent.IsControlDown() && TextEditor->CanExecuteCopy() ) 
	{
		// Copy text to clipboard
		TextEditor->CopySelectedTextToClipboard();
		
		return FReply::Handled();
	}


	// @Todo: Slate keybindings support more than one set of keys. 
	// Alternate key for paste (Shift+Insert) 
	else if( Key == EKeys::Insert && InKeyEvent.IsShiftDown() && TextEditor->CanExecutePaste() )
	{
		// Paste text from clipboard
		TextEditor->PasteTextFromClipboard();
		
		return FReply::Handled();
	}

	// @Todo: Slate keybindings support more than one set of keys. 
	//Alternate key for undo (Alt+Backspace)
	else if( Key == EKeys::BackSpace && InKeyEvent.IsAltDown() && !InKeyEvent.IsShiftDown() && TextEditor->CanExecuteUndo() )
	{
		// Undo
		TextEditor->Undo();
		
		return FReply::Handled();
	}

	// @Todo: Slate keybindings support more than one set of keys. 
	// Delete to previous word boundary (Ctrl+Backspace)
	else if( Key == EKeys::BackSpace && InKeyEvent.IsControlDown() && !InKeyEvent.IsAltDown() && !InKeyEvent.IsShiftDown() && !TextEditor->GetIsReadOnly() )
	{
		FScopedTextTransaction TextTransaction(TextEditor);

		TextEditor->MoveCursor( FMoveCursor::Cardinal(
			ECursorMoveGranularity::Word, 
			// Move left
			FIntPoint(-1, 0), 
			ECursorAction::SelectText
		));
		TextEditor->BackspaceChar();

		return FReply::Handled();
	}


	// Ctrl+Y (or Ctrl+Shift+Z, or Alt+Shift+Backspace) to redo
	else if( !TextEditor->GetIsReadOnly() && ( ( Key == EKeys::Y && InKeyEvent.IsControlDown() ) ||
		( Key == EKeys::Z && InKeyEvent.IsControlDown() && InKeyEvent.IsShiftDown() ) ||
		( Key == EKeys::BackSpace && InKeyEvent.IsAltDown() && InKeyEvent.IsShiftDown() ) ) )
	{
		// Redo
		TextEditor->Redo();
		
		return FReply::Handled();
	}
	else if( !InKeyEvent.IsAltDown() && !InKeyEvent.IsControlDown() && InKeyEvent.GetKey() != EKeys::Tab && InKeyEvent.GetCharacter() != 0 )
	{
		// Shift and a character was pressed or a single character was pressed.  We will type something in an upcoming OnKeyChar event.  
		// Absorb this event so it is not bubbled and handled by other widgets that could have something bound to the key press.

		//Note: Tab can generate a character code but not result in a typed character in this box so we ignore it.
		return FReply::Handled();
	}
	else
	{
		return FReply::Unhandled();
	}
}
开发者ID:xiangyuan,项目名称:Unreal4,代码行数:101,代码来源:TextEditHelper.cpp


注:本文中的TSharedRef::BackspaceChar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。