-
Notifications
You must be signed in to change notification settings - Fork 765
Expand file tree
/
Copy pathSPythonEditableText.cpp
More file actions
125 lines (112 loc) · 2.98 KB
/
SPythonEditableText.cpp
File metadata and controls
125 lines (112 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#include "SPythonEditableText.h"
#include "PythonEditorPrivatePCH.h"
void SPythonEditableText::Construct(const FArguments& InArgs)
{
SMultiLineEditableText::Construct(
SMultiLineEditableText::FArguments()
.Font(FPythonEditorStyle::Get().GetWidgetStyle<FTextBlockStyle>("TextEditor.NormalText").Font)
.TextStyle(&FPythonEditorStyle::Get().GetWidgetStyle<FTextBlockStyle>("TextEditor.NormalText"))
.Text(InArgs._Text)
.Marshaller(InArgs._Marshaller)
.AutoWrapText(false)
.Margin(0.0f)
.HScrollBar(InArgs._HScrollBar)
.VScrollBar(InArgs._VScrollBar)
.OnTextChanged(InArgs._OnTextChanged)
.OnCursorMoved(this, &SPythonEditableText::OnCursorMoved)
);
OnExecuted = InArgs._OnExecuted;
CurrentScale = 1;
}
FReply SPythonEditableText::OnKeyChar(const FGeometry& MyGeometry, const FCharacterEvent& InCharacterEvent)
{
FReply Reply = FReply::Unhandled();
const TCHAR Character = InCharacterEvent.GetCharacter();
if (IsTextReadOnly())
{
return Reply;
}
Reply = FReply::Handled();
if (Character == TEXT('\t'))
{
FString String;
String.AppendChar(Character);
InsertTextAtCursor(String);
}
//else if (Character == TEXT('('))
//{
// FString String=TEXT("()");
// InsertTextAtCursor(String);
//}
//else if (Character == TEXT('['))
//{
// FString String = TEXT("[]");
// InsertTextAtCursor(String);
//}
//else if (Character == TEXT('{'))
//{
// FString String = TEXT("{}");
// InsertTextAtCursor(String);
//}
//else if (Character == TEXT('\''))
//{
// FString String = TEXT("''");
// InsertTextAtCursor(String);
//}
//else if (Character == TEXT('"'))
//{
// FString String = TEXT("\"\"");
// InsertTextAtCursor(String);
//}
else
{
Reply = SMultiLineEditableText::OnKeyChar(MyGeometry, InCharacterEvent);
}
return Reply;
}
FReply SPythonEditableText::OnMouseWheel(const FGeometry& MyGeometry, const FPointerEvent& InPointerEvent)
{
if (FSlateApplication::Get().GetModifierKeys().IsControlDown())
{
if (InPointerEvent.GetWheelDelta() > 0)
{
CurrentScale += 0.1;
}
else if (InPointerEvent.GetWheelDelta() < 0)
{
CurrentScale -= 0.1;
}
if (CurrentScale < 1)
CurrentScale = 1;
SetRenderTransform(FSlateRenderTransform(CurrentScale));
return FReply::Handled();
}
return SMultiLineEditableText::OnMouseWheel(MyGeometry, InPointerEvent);
}
FReply SPythonEditableText::OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent)
{
FReply Reply = FReply::Unhandled();
if (InKeyEvent.GetKeyCode() == 9)
{
Reply = FReply::Handled();
}
else if (InKeyEvent.IsControlDown() && InKeyEvent.GetKeyCode() == 13)
{
Reply = FReply::Handled();
OnExecuted.Execute();
}
else
{
Reply = SMultiLineEditableText::OnKeyDown(MyGeometry, InKeyEvent);
}
//FString test;
//test=FString::FromInt(InKeyEvent.GetKeyCode());
//InsertTextAtCursor(test);
return Reply;
}
void SPythonEditableText::GetLineAndColumn(int32 & Line, int32 & Column)
{
Line = CurrentLine;
Column = CurrentColumn;
}