From a5632c08c7977f5a88c6cc01ae4d029fda1d3cbe Mon Sep 17 00:00:00 2001 From: Lirusaito Date: Wed, 16 Jan 2019 14:33:53 -0500 Subject: [PATCH] Add "Copy URL" option to text editor right click menu when right clicking links. --- indra/llui/lltexteditor.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 6716fc2f5..1796265ac 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -360,6 +360,13 @@ LLTextEditor::LLTextEditor( menu->addChild(new LLMenuItemCallGL("Copy Raw", [](void* data) { if (LLTextEditor* line = static_cast(data)) line->copyRaw(); }, NULL, this)); + menu->addChild(new LLMenuItemCallGL("Copy URL", [](void* data) { + if (std::string* str = static_cast(data)) + { + auto url = utf8str_to_wstring(*str); + gClipboard.copyFromSubstring(url, 0, url.size()); + } + }, NULL, this)); menu->addChild(new LLMenuItemCallGL("Paste", context_paste, NULL, this)); menu->addChild(new LLMenuItemCallGL("Delete", context_delete, NULL, this)); menu->addChild(new LLMenuItemCallGL("Select All", context_selectall, NULL, this)); @@ -1455,6 +1462,18 @@ BOOL LLTextEditor::handleRightMouseDown( S32 x, S32 y, MASK mask ) suggestionMenuItems.push_back(tempStruct); menu->addChild(suggMenuItem); } + + { + const LLStyleSP style = mHoverSegment ? mHoverSegment->getStyle() : nullptr; + auto copy_url = menu->findChild("Copy URL"); + if (mReadOnly && mParseHTML && style && !style->getLinkHREF().empty()) + { + copy_url->setVisible(true); + copy_url->setUserData((void*)&style->getLinkHREF()); // Yes, this can be invalidated, but they'll never click it then. + } + else copy_url->setVisible(false); + } + mLastContextMenuX = x; mLastContextMenuY = y; menu->buildDrawLabels();