From 5687e3ebba9b504ebf1c4763dcb95c2b93761b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lup=C4=8D=C3=ADk?= Date: Fri, 17 Nov 2023 18:39:42 +0100 Subject: [PATCH] Pass the focused input via ActivateKeyboard --- Backends/RmlUi_Platform_Win32.cpp | 2 +- Backends/RmlUi_Platform_Win32.h | 2 +- Include/RmlUi/Core/SystemInterface.h | 5 ++++- Source/Core/Elements/WidgetTextInput.cpp | 2 +- Source/Core/SystemInterface.cpp | 2 +- Source/Debugger/DebuggerSystemInterface.cpp | 4 ++-- Source/Debugger/DebuggerSystemInterface.h | 2 +- 7 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Backends/RmlUi_Platform_Win32.cpp b/Backends/RmlUi_Platform_Win32.cpp index 489a4581a..6e008e485 100644 --- a/Backends/RmlUi_Platform_Win32.cpp +++ b/Backends/RmlUi_Platform_Win32.cpp @@ -148,7 +148,7 @@ void SystemInterface_Win32::GetClipboardText(Rml::String& text) } } -void SystemInterface_Win32::ActivateKeyboard(Rml::Vector2f caret_position, float /*line_height*/) +void SystemInterface_Win32::ActivateKeyboard(Rml::Vector2f caret_position, float /*line_height*/, Rml::ElementFormControl* /*focused_input*/) { // Adjust the position of the input method editor (IME) to the caret. if (HIMC himc = ImmGetContext(window_handle)) diff --git a/Backends/RmlUi_Platform_Win32.h b/Backends/RmlUi_Platform_Win32.h index b040c3501..c035cd6d6 100644 --- a/Backends/RmlUi_Platform_Win32.h +++ b/Backends/RmlUi_Platform_Win32.h @@ -51,7 +51,7 @@ class SystemInterface_Win32 : public Rml::SystemInterface { void SetClipboardText(const Rml::String& text) override; void GetClipboardText(Rml::String& text) override; - void ActivateKeyboard(Rml::Vector2f caret_position, float line_height) override; + void ActivateKeyboard(Rml::Vector2f caret_position, float line_height, Rml::ElementFormControl* focused_input) override; private: HWND window_handle = nullptr; diff --git a/Include/RmlUi/Core/SystemInterface.h b/Include/RmlUi/Core/SystemInterface.h index 1e94ee6d5..82d04fa8f 100644 --- a/Include/RmlUi/Core/SystemInterface.h +++ b/Include/RmlUi/Core/SystemInterface.h @@ -36,6 +36,8 @@ namespace Rml { +class ElementFormControl; + /** RmlUi's System Interface. @@ -93,7 +95,8 @@ class RMLUICORE_API SystemInterface : public NonCopyMoveable { /// Activate keyboard (for touchscreen devices). /// @param[in] caret_position Position of the caret in absolute window coordinates. /// @param[in] line_height Height of the current line being edited. - virtual void ActivateKeyboard(Rml::Vector2f caret_position, float line_height); + /// @param[in] focused_input Affected input/textarea element. + virtual void ActivateKeyboard(Rml::Vector2f caret_position, float line_height, ElementFormControl* focused_input); /// Deactivate keyboard (for touchscreen devices). virtual void DeactivateKeyboard(); diff --git a/Source/Core/Elements/WidgetTextInput.cpp b/Source/Core/Elements/WidgetTextInput.cpp index ee1d910d1..6cf7ec96f 100644 --- a/Source/Core/Elements/WidgetTextInput.cpp +++ b/Source/Core/Elements/WidgetTextInput.cpp @@ -1393,7 +1393,7 @@ void WidgetTextInput::SetKeyboardActive(bool active) const Vector2f element_offset = parent->GetAbsoluteOffset() - scroll_offset; const Vector2f absolute_cursor_position = element_offset + cursor_position + Vector2f(0, 1); const float line_height = cursor_size.y - 2.f; - system->ActivateKeyboard(absolute_cursor_position, line_height); + system->ActivateKeyboard(absolute_cursor_position, line_height, parent); } else { diff --git a/Source/Core/SystemInterface.cpp b/Source/Core/SystemInterface.cpp index 72456adb8..ab650d2c5 100644 --- a/Source/Core/SystemInterface.cpp +++ b/Source/Core/SystemInterface.cpp @@ -130,7 +130,7 @@ void SystemInterface::JoinPath(String& translated_path, const String& document_p translated_path = Replace(url.GetPathedFileName(), '|', ':'); } -void SystemInterface::ActivateKeyboard(Rml::Vector2f /*caret_position*/, float /*line_height*/) {} +void SystemInterface::ActivateKeyboard(Rml::Vector2f /*caret_position*/, float /*line_height*/, ElementFormControl* /*focused_input*/) {} void SystemInterface::DeactivateKeyboard() {} diff --git a/Source/Debugger/DebuggerSystemInterface.cpp b/Source/Debugger/DebuggerSystemInterface.cpp index 91912ff9e..0b1f593cb 100644 --- a/Source/Debugger/DebuggerSystemInterface.cpp +++ b/Source/Debugger/DebuggerSystemInterface.cpp @@ -80,9 +80,9 @@ void DebuggerSystemInterface::GetClipboardText(String& text) application_interface->GetClipboardText(text); } -void DebuggerSystemInterface::ActivateKeyboard(Rml::Vector2f caret_position, float line_height) +void DebuggerSystemInterface::ActivateKeyboard(Rml::Vector2f caret_position, float line_height, ElementFormControl* focused_input) { - application_interface->ActivateKeyboard(caret_position, line_height); + application_interface->ActivateKeyboard(caret_position, line_height, focused_input); } void DebuggerSystemInterface::DeactivateKeyboard() diff --git a/Source/Debugger/DebuggerSystemInterface.h b/Source/Debugger/DebuggerSystemInterface.h index 33421bf61..5d0bdea5f 100644 --- a/Source/Debugger/DebuggerSystemInterface.h +++ b/Source/Debugger/DebuggerSystemInterface.h @@ -85,7 +85,7 @@ class DebuggerSystemInterface : public Rml::SystemInterface { void GetClipboardText(String& text) override; /// Activate keyboard (for touchscreen devices). - void ActivateKeyboard(Rml::Vector2f caret_position, float line_height) override; + void ActivateKeyboard(Rml::Vector2f caret_position, float line_height, ElementFormControl* focused_input) override; /// Deactivate keyboard (for touchscreen devices). void DeactivateKeyboard() override;