diff options
Diffstat (limited to 'Minecraft.Client/Common/UI/UIControl_TextInput.cpp')
| -rw-r--r-- | Minecraft.Client/Common/UI/UIControl_TextInput.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Minecraft.Client/Common/UI/UIControl_TextInput.cpp b/Minecraft.Client/Common/UI/UIControl_TextInput.cpp index 8e679b7c..76f25afb 100644 --- a/Minecraft.Client/Common/UI/UIControl_TextInput.cpp +++ b/Minecraft.Client/Common/UI/UIControl_TextInput.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "UI.h" #include "UIControl_TextInput.h" +#include "..\..\Screen.h" UIControl_TextInput::UIControl_TextInput() { @@ -211,6 +212,31 @@ UIControl_TextInput::EDirectEditResult UIControl_TextInput::tickDirectEdit() } } + // Paste from clipboard + if (g_KBMInput.IsKeyPressed('V') && g_KBMInput.IsKeyDown(VK_CONTROL)) + { + wstring pasted = Screen::getClipboard(); + wstring sanitized; + sanitized.reserve(pasted.length()); + + for (wchar_t pc : pasted) + { + if (pc >= 0x20) // Keep printable characters + { + if (m_iCharLimit > 0 && (m_editBuffer.length() + sanitized.length()) >= (size_t)m_iCharLimit) + break; + sanitized += pc; + } + } + + if (!sanitized.empty()) + { + m_editBuffer.insert(m_iCursorPos, sanitized); + m_iCursorPos += (int)sanitized.length(); + changed = true; + } + } + // Arrow keys, Home, End, Delete for cursor movement if (g_KBMInput.IsKeyPressed(VK_LEFT) && m_iCursorPos > 0) { |
