From 26f0a9fec934f0bff088aad92e1814a7dae8ac8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Thu, 12 Apr 2018 13:42:36 +0200 Subject: [PATCH] Sdk/Console: Add ClearFocus/SetFocus methods Theses should be virtuals --- SDK/include/NDK/Console.hpp | 2 ++ SDK/src/NDK/Console.cpp | 25 +++++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/SDK/include/NDK/Console.hpp b/SDK/include/NDK/Console.hpp index 1f6e5f9a1..ae6b63b48 100644 --- a/SDK/include/NDK/Console.hpp +++ b/SDK/include/NDK/Console.hpp @@ -42,6 +42,7 @@ namespace Ndk void AddLine(const Nz::String& text, const Nz::Color& color = Nz::Color::White); void Clear(); + void ClearFocus(); inline unsigned int GetCharacterSize() const; inline const TextAreaWidget* GetHistory() const; @@ -51,6 +52,7 @@ namespace Ndk void ResizeToContent() override; void SetCharacterSize(unsigned int size); + void SetFocus(); void SetTextFont(Nz::FontRef font); Console& operator=(const Console& console) = delete; diff --git a/SDK/src/NDK/Console.cpp b/SDK/src/NDK/Console.cpp index 184d6e9d2..f1f43ed9d 100644 --- a/SDK/src/NDK/Console.cpp +++ b/SDK/src/NDK/Console.cpp @@ -103,7 +103,6 @@ namespace Ndk * \param text New line of text * \param color Color for the text */ - void Console::AddLine(const Nz::String& text, const Nz::Color& color) { m_historyLines.emplace_back(Line{ color, text }); @@ -112,8 +111,9 @@ namespace Ndk /*! * \brief Clears the console + * + * Clears the console history and input */ - void Console::Clear() { m_historyLines.clear(); @@ -121,6 +121,16 @@ namespace Ndk m_input->SetText(s_inputPrefix); } + /*! + * \brief Clears the console focus + * + * Clear console input widget focus (if owned) + */ + void Console::ClearFocus() + { + m_input->ClearFocus(); + } + void Console::ResizeToContent() { } @@ -130,7 +140,6 @@ namespace Ndk * * \param size Size of the font */ - void Console::SetCharacterSize(unsigned int size) { m_characterSize = size; @@ -141,6 +150,15 @@ namespace Ndk Layout(); } + /*! + * \brief Give the console input focus + * + */ + void Console::SetFocus() + { + m_input->SetFocus(); + } + /*! * \brief Sets the text font * @@ -148,7 +166,6 @@ namespace Ndk * * \remark Produces a NazaraAssert if font is invalid or null */ - void Console::SetTextFont(Nz::FontRef font) { NazaraAssert(font && font->IsValid(), "Invalid font");