diff options
| author | Maxim Nikolenko <maximnproductengine@lindenlab.com> | 2026-04-15 18:03:44 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-15 18:03:44 +0300 |
| commit | d9b6ba6bb908085464e02c89cbecec94edfd1ee7 (patch) | |
| tree | 8072695e41f297d1a8771a4a1b812743b953b6ae /indra | |
| parent | 8c2dc66d81902c5ad4f42b50b492d1c7025eb2ad (diff) | |
#5450 add Leap unicode input support
Diffstat (limited to 'indra')
| -rw-r--r-- | indra/newview/llwindowlistener.cpp | 63 | ||||
| -rw-r--r-- | indra/newview/llwindowlistener.h | 1 |
2 files changed, 64 insertions, 0 deletions
diff --git a/indra/newview/llwindowlistener.cpp b/indra/newview/llwindowlistener.cpp index 6d234a9a34..31005fb734 100644 --- a/indra/newview/llwindowlistener.cpp +++ b/indra/newview/llwindowlistener.cpp @@ -41,6 +41,8 @@ #include "llrootview.h" #include "llsdutil.h" #include "stringize.h" +#include "llclipboard.h" +#include "lleditmenuhandler.h" #include <functional> #include <typeinfo> #include <map> @@ -107,6 +109,10 @@ LLWindowListener::LLWindowListener(LLViewerWindow *window, const KeyboardGetter& "Given an integer number of [\"clicks\"], inject the requested mouse scroll event.\n" "(positive clicks moves downward through typical content)", &LLWindowListener::mouseScroll); + add("pasteText", + "Paste specified [\"text\"] into the current edit field\n" + "Optional [\"path\"] specifies target UI element (must be focusable).", + &LLWindowListener::pasteText); } template <typename MAPPED> @@ -521,3 +527,60 @@ void LLWindowListener::mouseScroll(LLSD const & request) mWindow->handleScrollWheel(NULL, clicks); } + +void LLWindowListener::pasteText(LLSD const & evt) +{ + Response response(LLSD(), evt); + + if (!evt.has("text")) + { + response.error(STRINGIZE(evt["op"].asString() << " request did not provide required \"text\" parameter")); + return; + } + + std::string text_to_paste = evt["text"].asString(); + if (evt.has("path")) + { + std::string path(evt["path"]); + LLView* target_view = LLUI::getInstance()->resolvePath(LLUI::getInstance()->getRootView(), path); + if (!target_view) + { + response.error(STRINGIZE(evt["op"].asString() << " request specified invalid \"path\": " << path)); + return; + } + else if(!target_view->isAvailable()) + { + response.error(STRINGIZE("Target view specified by \"path\": " << path << " is not visible")); + return; + } + else + { + // Focus the target view + gFocusMgr.setKeyboardFocus(target_view); + } + } + + // Check if edit menu handler is available + if (!LLEditMenuHandler::gEditMenuHandler) + { + response.error(STRINGIZE(evt["op"].asString() << " request failed: no edit menu handler available")); + return; + } + + // Save current clipboard contents + LLWString saved_clipboard; + LLClipboard::instance().pasteFromClipboard(saved_clipboard); + + LLClipboard::instance().copyToClipboard(utf8str_to_wstring(text_to_paste), 0, static_cast<S32>(text_to_paste.size())); + LLEditMenuHandler::gEditMenuHandler->paste(); + + // Restore original clipboard contents if there were any + if (!saved_clipboard.empty()) + { + LLClipboard::instance().copyToClipboard(saved_clipboard, 0, static_cast<S32>(saved_clipboard.size())); + } + else + { + LLClipboard::instance().reset(); + } +} diff --git a/indra/newview/llwindowlistener.h b/indra/newview/llwindowlistener.h index 9908a9c451..d3a16cfde9 100644 --- a/indra/newview/llwindowlistener.h +++ b/indra/newview/llwindowlistener.h @@ -47,6 +47,7 @@ public: void mouseUp(LLSD const & evt); void mouseMove(LLSD const & evt); void mouseScroll(LLSD const & evt); + void pasteText(LLSD const & evt); private: LLViewerWindow * mWindow; |
