Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass the focused input via ActivateKeyboard #540

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Backends/RmlUi_Platform_Win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion Backends/RmlUi_Platform_Win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion Include/RmlUi/Core/SystemInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

namespace Rml {

class ElementFormControl;

/**
RmlUi's System Interface.

Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Elements/WidgetTextInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/SystemInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

Expand Down
4 changes: 2 additions & 2 deletions Source/Debugger/DebuggerSystemInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion Source/Debugger/DebuggerSystemInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down