Right click linked names/groups/objects in chat, copy key

This commit is contained in:
Lirusaito
2019-02-03 17:38:43 -05:00
parent d29832ce5c
commit 0478d90578
6 changed files with 35 additions and 4 deletions

View File

@@ -406,12 +406,13 @@ class ContextText : public LLMemberListener<LLView>
}
};
static const std::string& get_focused_url()
{
return get_focused_text_editor()->getMenuSegmentUrl();
}
class ContextUrl : public LLMemberListener<LLView>
{
static const std::string& get_focused_url()
{
return get_focused_text_editor()->getMenuSegmentUrl();
}
bool handleEvent(LLPointer<LLOldEvents::LLEvent>, const LLSD& userdata) override
{
const auto& url = get_focused_url();
@@ -434,6 +435,20 @@ class ContextUrl : public LLMemberListener<LLView>
}
};
class ContextUrlCopy : public LLMemberListener<LLView>
{
bool handleEvent(LLPointer<LLOldEvents::LLEvent>, const LLSD& userdata) override
{
const auto& url = get_focused_url();
const auto& type = userdata.asStringRef();
// Empty works like avatar and group, "object" is an object (you needed to be told this)
const auto& id = type.empty() ? LLUrlAction::getUserID(url) : LLUrlAction::getObjectId(url);
LLView::getWindow()->copyTextToClipboard(utf8str_to_wstring(id));
return true;
}
};
void LLTextEditor::spell_correct(void* data)
{
@@ -516,6 +531,7 @@ void LLTextEditor::addMenuListeners()
{
(new ContextText)->registerListener(LLMenuGL::sMenuContainer, "Text");
(new ContextUrl)->registerListener(LLMenuGL::sMenuContainer, "Text.Url");
(new ContextUrlCopy)->registerListener(LLMenuGL::sMenuContainer, "Text.Url.CopyUUID");
}
void LLTextEditor::setTrackColor( const LLColor4& color )

View File

@@ -47,6 +47,9 @@
<menu_item_call.on_click
function="Text.Url" userdata="CopyUrl" />
</menu_item_call>
<menu_item_call label="Copy Key to clipboard" name="key_copy">
<menu_item_call.on_click function="Text.Url.CopyUUID" />
</menu_item_call>
<menu_item_call label="Select All" name="Select All">
<on_click function="Text" userdata="SelectAll"/>
</menu_item_call>

View File

@@ -26,6 +26,9 @@
<menu_item_call.on_click
function="Text.Url" userdata="CopyUrl" />
</menu_item_call>
<menu_item_call label="Copy Key to clipboard" name="key_copy">
<menu_item_call.on_click function="Text.Url.CopyUUID" />
</menu_item_call>
<menu_item_call label="Select All" name="Select All">
<on_click function="Text" userdata="SelectAll"/>
</menu_item_call>

View File

@@ -10,6 +10,9 @@
<menu_item_call.on_click
function="Text.Url" userdata="CopyUrl" />
</menu_item_call>
<menu_item_call label="Copy Key to clipboard" name="key_copy">
<menu_item_call.on_click function="Text.Url.CopyUUID" />
</menu_item_call>
<menu_item_call label="Select All" name="Select All">
<on_click function="Text" userdata="SelectAll"/>
</menu_item_call>

View File

@@ -26,6 +26,9 @@
<menu_item_call.on_click
function="Text.Url" userdata="CopyUrl" />
</menu_item_call>
<menu_item_call label="Copy Key to clipboard" name="key_copy">
<menu_item_call.on_click function="Text.Url.CopyUUID" />
</menu_item_call>
<menu_item_call label="Select All" name="Select All">
<on_click function="Text" userdata="SelectAll"/>
</menu_item_call>

View File

@@ -56,6 +56,9 @@
<menu_item_call.on_click
function="Text.Url" userdata="CopyUrl" />
</menu_item_call>
<menu_item_call label="Copy Key to clipboard" name="key_copy">
<menu_item_call.on_click function="Text.Url.CopyUUID" userdata="object"/>
</menu_item_call>
<menu_item_call label="Select All" name="Select All">
<on_click function="Text" userdata="SelectAll"/>
</menu_item_call>