| 187 | |
| 188 | |
| 189 | void SPythonConsoleInputBox::OnTextCommitted(const FText& InText, ETextCommit::Type CommitInfo) |
| 190 | { |
| 191 | if (CommitInfo == ETextCommit::OnEnter) |
| 192 | { |
| 193 | if (!InText.IsEmpty()) |
| 194 | { |
| 195 | |
| 196 | // Copy the exec text string out so we can clear the widget's contents. If the exec command spawns |
| 197 | // a new window it can cause the text box to lose focus, which will result in this function being |
| 198 | // re-entered. We want to make sure the text string is empty on re-entry, so we'll clear it out |
| 199 | const FString ExecString = InText.ToString(); |
| 200 | |
| 201 | this->History.Add(ExecString); |
| 202 | this->HistoryPosition = this->History.Num(); |
| 203 | |
| 204 | UE_LOG(LogTemp, Log, TEXT(">>> %s"), *ExecString); |
| 205 | |
| 206 | // Clear the console input area |
| 207 | bIgnoreUIUpdate = true; |
| 208 | InputText->SetText(FText::GetEmpty()); |
| 209 | bIgnoreUIUpdate = false; |
| 210 | |
| 211 | // Here run the python code |
| 212 | // |
| 213 | FUnrealEnginePythonModule &PythonModule = FModuleManager::GetModuleChecked<FUnrealEnginePythonModule>("UnrealEnginePython"); |
| 214 | PythonModule.RunString(TCHAR_TO_UTF8(*ExecString)); |
| 215 | |
| 216 | |
| 217 | } |
| 218 | |
| 219 | } |
| 220 | |
| 221 | OnConsoleCommandExecuted.ExecuteIfBound(); |
| 222 | } |
| 223 | |
| 224 | |
| 225 | TSharedRef< FPythonLogTextLayoutMarshaller > FPythonLogTextLayoutMarshaller::Create(TArray< TSharedPtr<FLogMessage> > InMessages) |