Merge Line Editor menu and Text Editor menu, and use EditMenu listeners
Cleans up a ton of logic and some excess memory usage Translates Line Editor menu, finally
This commit is contained in:
@@ -178,18 +178,9 @@ LLLineEditor::LLLineEditor(const std::string& name, const LLRect& rect,
|
||||
sImage = LLUI::getUIImage("sm_rounded_corners_simple.tga");
|
||||
}
|
||||
mImage = sImage;
|
||||
|
||||
// make the popup menu available
|
||||
//LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_texteditor.xml", parent_view);
|
||||
LLMenuGL* menu = new LLMenuGL("wot");
|
||||
/*if (!menu)
|
||||
{
|
||||
menu = new LLMenuGL(LLStringUtil::null);
|
||||
}*/
|
||||
menu->addChild(new LLMenuItemCallGL("Cut", context_cut, NULL, this));
|
||||
menu->addChild(new LLMenuItemCallGL("Copy", context_copy, 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));
|
||||
LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_texteditor.xml", LLMenuGL::sMenuContainer);
|
||||
menu->addSeparator();
|
||||
//menu->setBackgroundColor(gColors.getColor("MenuPopupBgColor"));
|
||||
menu->setCanTearOff(FALSE);
|
||||
@@ -452,18 +443,6 @@ void LLLineEditor::deselect()
|
||||
}
|
||||
|
||||
|
||||
void LLLineEditor::context_cut(void* data)
|
||||
{
|
||||
LLLineEditor* line = (LLLineEditor*)data;
|
||||
if(line)line->cut();
|
||||
}
|
||||
void LLLineEditor::context_copy(void* data)
|
||||
{
|
||||
LLLineEditor* line = (LLLineEditor*)data;
|
||||
if(line)line->copy();
|
||||
}
|
||||
|
||||
|
||||
void LLLineEditor::spell_correct(void* data)
|
||||
{
|
||||
SpellMenuBind* tempBind = (SpellMenuBind*)data;
|
||||
@@ -545,25 +524,6 @@ void LLLineEditor::spell_add(void* data)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LLLineEditor::context_paste(void* data)
|
||||
{
|
||||
LLLineEditor* line = (LLLineEditor*)data;
|
||||
if(line)line->paste();
|
||||
}
|
||||
|
||||
void LLLineEditor::context_delete(void* data)
|
||||
{
|
||||
LLLineEditor* line = (LLLineEditor*)data;
|
||||
if(line)line->doDelete();
|
||||
}
|
||||
|
||||
void LLLineEditor::context_selectall(void* data)
|
||||
{
|
||||
LLLineEditor* line = (LLLineEditor*)data;
|
||||
if(line)line->selectAll();
|
||||
}
|
||||
|
||||
void LLLineEditor::startSelection()
|
||||
{
|
||||
mIsSelecting = TRUE;
|
||||
@@ -3113,7 +3073,6 @@ void LLLineEditor::showContextMenu(S32 x, S32 y)
|
||||
tempStruct->wordPositionStart=wordStart;
|
||||
LLMenuItemCallGL * suggMenuItem = new LLMenuItemCallGL(
|
||||
tempStruct->word, spell_correct, NULL, tempStruct);
|
||||
//new LLMenuItemCallGL("Select All", context_selectall, NULL, this));
|
||||
tempStruct->menuItem = suggMenuItem;
|
||||
suggestionMenuItems.push_back(tempStruct);
|
||||
menu->addChild(suggMenuItem);
|
||||
|
||||
@@ -137,11 +137,6 @@ public:
|
||||
virtual void deselect();
|
||||
virtual BOOL canDeselect() const;
|
||||
|
||||
static void context_cut(void* data);
|
||||
static void context_copy(void* data);
|
||||
static void context_paste(void* data);
|
||||
static void context_delete(void* data);
|
||||
static void context_selectall(void* data);
|
||||
static void spell_correct(void* data);
|
||||
static void spell_show(void* data);
|
||||
static void spell_add(void* data);
|
||||
|
||||
@@ -397,18 +397,20 @@ static LLTextEditor* get_focused_text_editor()
|
||||
return te;
|
||||
}
|
||||
|
||||
class ContextText : public LLMemberListener<LLView>
|
||||
class CopyRawText : public LLMemberListener<LLView>
|
||||
{
|
||||
bool handleEvent(LLPointer<LLOldEvents::LLEvent>, const LLSD& userdata) override
|
||||
{
|
||||
auto text = get_focused_text_editor();
|
||||
const auto& op = userdata.asStringRef();
|
||||
if (op == "Cut") text->cut();
|
||||
else if (op == "Copy") text->copy();
|
||||
else if (op == "CopyRaw") text->copyRaw();
|
||||
else if (op == "Paste") text->paste();
|
||||
else if (op == "Delete") text->doDelete();
|
||||
else if (op == "SelectAll") text->selectAll();
|
||||
get_focused_text_editor()->copyRaw();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class TextEditorVisible : public LLMemberListener<LLView>
|
||||
{
|
||||
bool handleEvent(LLPointer<LLOldEvents::LLEvent>, const LLSD& userdata) override
|
||||
{
|
||||
LLMenuGL::sMenuContainer->findControl(userdata["control"].asString())->setValue(!!dynamic_cast<LLTextEditor*>(gFocusMgr.getKeyboardFocus()));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -583,7 +585,8 @@ void LLTextEditor::spell_add(void* data)
|
||||
//static
|
||||
void LLTextEditor::addMenuListeners(ext_slurl_cb cb, ext_slurl_visible_cb vcb)
|
||||
{
|
||||
(new ContextText)->registerListener(LLMenuGL::sMenuContainer, "Text");
|
||||
(new CopyRawText)->registerListener(LLMenuGL::sMenuContainer, "CopyRawText");
|
||||
(new TextEditorVisible)->registerListener(LLMenuGL::sMenuContainer, "TextEditorVisible");
|
||||
(new ContextUrl)->registerListener(LLMenuGL::sMenuContainer, "Text.Url");
|
||||
(new ContextUrlCopy)->registerListener(LLMenuGL::sMenuContainer, "Text.Url.CopyUUID");
|
||||
(new ContextUrlExt(cb))->registerListener(LLMenuGL::sMenuContainer, "Text.Url.Ext");
|
||||
|
||||
@@ -1,21 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
|
||||
<menu name="rclickmenu" create_jump_keys="true">
|
||||
<menu name="rclickmenu" label="Text" create_jump_keys="true">
|
||||
<menu_item_call label="Cut" name="Cut">
|
||||
<on_click function="Text" userdata="Cut"/>
|
||||
<on_click function="Edit.Cut"/>
|
||||
<on_visible function="Edit.EnableCut" />
|
||||
</menu_item_call>
|
||||
<menu_item_call label="Copy" name="Copy">
|
||||
<on_click function="Text" userdata="Copy"/>
|
||||
<on_click function="Edit.Copy"/>
|
||||
<on_enable function="Edit.EnableCopy" />
|
||||
</menu_item_call>
|
||||
<menu_item_call label="Copy Raw" name="Copy Raw">
|
||||
<on_click function="Text" userdata="CopyRaw"/>
|
||||
<on_click function="CopyRawText"/>
|
||||
<on_visible function="TextEditorVisible"/>
|
||||
</menu_item_call>
|
||||
<menu_item_call label="Paste" name="Paste">
|
||||
<on_click function="Text" userdata="Paste"/>
|
||||
<on_click function="Edit.Paste"/>
|
||||
<on_visible function="Edit.EnablePaste" />
|
||||
</menu_item_call>
|
||||
<menu_item_call label="Delete" name="Delete">
|
||||
<on_click function="Text" userdata="Delete"/>
|
||||
<on_click function="Edit.Delete"/>
|
||||
<on_visible function="Edit.EnableDelete" />
|
||||
</menu_item_call>
|
||||
<menu_item_call label="Select All" name="Select All">
|
||||
<on_click function="Text" userdata="SelectAll"/>
|
||||
<on_click function="Edit.SelectAll"/>
|
||||
</menu_item_call>
|
||||
</menu>
|
||||
|
||||
Reference in New Issue
Block a user