summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuri Chebotarev <ychebotarev@productengine.com>2009-12-02 19:37:33 +0200
committerYuri Chebotarev <ychebotarev@productengine.com>2009-12-02 19:37:33 +0200
commiteae60da6839906059d904c12cc155f4c2738c893 (patch)
treef9353557f79e684b3fa6aae3de823a9129a103c2
parentabbf49759dd525ce04e25275c97c548f47f5412c (diff)
fix for EXT-2886 Context menu for Nearby chat text field should look like context menu for any text editor, should include such items as (cut,copy, paste etc)
--HG-- branch : product-engine
-rw-r--r--indra/newview/llbottomtray.cpp93
-rw-r--r--indra/newview/llbottomtray.h4
-rw-r--r--indra/newview/skins/default/xui/en/menu_bottomtray.xml53
3 files changed, 149 insertions, 1 deletions
diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp
index 9cc7b8c785..10ebd5d8dc 100644
--- a/indra/newview/llbottomtray.cpp
+++ b/indra/newview/llbottomtray.cpp
@@ -45,6 +45,7 @@
#include "llsplitbutton.h"
#include "llsyswellwindow.h"
#include "llfloatercamera.h"
+#include "lltexteditor.h"
LLBottomTray::LLBottomTray(const LLSD&)
: mChicletPanel(NULL),
@@ -254,7 +255,9 @@ void LLBottomTray::showBottomTrayContextMenu(S32 x, S32 y, MASK mask)
// We should show BottomTrayContextMenu in last turn
if (mBottomTrayContextMenu && !LLMenuGL::sMenuContainer->getVisibleMenu())
{
- //there are no other context menu (IM chiclet etc ), so we can show BottomTrayContextMenu
+ //there are no other context menu (IM chiclet etc ), so we can show BottomTrayContextMenu
+
+ updateContextMenu(x, y, mask);
mBottomTrayContextMenu->buildDrawLabels();
mBottomTrayContextMenu->updateParent(LLMenuGL::sMenuContainer);
LLMenuGL::showPopup(this, mBottomTrayContextMenu, x, y);
@@ -262,6 +265,33 @@ void LLBottomTray::showBottomTrayContextMenu(S32 x, S32 y, MASK mask)
}
}
+void LLBottomTray::updateContextMenu(S32 x, S32 y, MASK mask)
+{
+ LLUICtrl* edit_box = mNearbyChatBar->getChild<LLUICtrl>("chat_box");
+
+ S32 local_x = x - mNearbyChatBar->getRect().mLeft - edit_box->getRect().mLeft;
+ S32 local_y = y - mNearbyChatBar->getRect().mBottom - edit_box->getRect().mBottom;
+
+ bool in_edit_box = edit_box->pointInView(local_x, local_y);
+
+ LLMenuItemGL* menu_item;
+ menu_item = mBottomTrayContextMenu->findChild<LLMenuItemGL>("NearbyChatBar_Cut");
+ if(menu_item)
+ menu_item->setVisible(in_edit_box);
+ menu_item = mBottomTrayContextMenu->findChild<LLMenuItemGL>("NearbyChatBar_Copy");
+ if(menu_item)
+ menu_item->setVisible(in_edit_box);
+ menu_item = mBottomTrayContextMenu->findChild<LLMenuItemGL>("NearbyChatBar_Paste");
+ if(menu_item)
+ menu_item->setVisible(in_edit_box);
+ menu_item = mBottomTrayContextMenu->findChild<LLMenuItemGL>("NearbyChatBar_Delete");
+ if(menu_item)
+ menu_item->setVisible(in_edit_box);
+ menu_item = mBottomTrayContextMenu->findChild<LLMenuItemGL>("NearbyChatBar_Select_All");
+ if(menu_item)
+ menu_item->setVisible(in_edit_box);
+}
+
void LLBottomTray::showGestureButton(BOOL visible)
{
setTrayButtonVisibleIfPossible(RS_BUTTON_GESTURES, visible);
@@ -293,9 +323,14 @@ namespace
BOOL LLBottomTray::postBuild()
{
+
+ LLUICtrl::CommitCallbackRegistry::currentRegistrar().add("NearbyChatBar.Action", boost::bind(&LLBottomTray::onContextMenuItemClicked, this, _2));
+ LLUICtrl::EnableCallbackRegistry::currentRegistrar().add("NearbyChatBar.EnableMenuItem", boost::bind(&LLBottomTray::onContextMenuItemEnabled, this, _2));
+
mBottomTrayContextMenu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_bottomtray.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
gMenuHolder->addChild(mBottomTrayContextMenu);
+
mNearbyChatBar = getChild<LLNearbyChatBar>("chat_bar");
mToolbarStack = getChild<LLLayoutStack>("toolbar_stack");
mMovementPanel = getChild<LLPanel>("movement_panel");
@@ -328,6 +363,62 @@ BOOL LLBottomTray::postBuild()
return TRUE;
}
+bool LLBottomTray::onContextMenuItemEnabled(const LLSD& userdata)
+{
+ std::string item = userdata.asString();
+ LLLineEditor* edit_box = mNearbyChatBar->findChild<LLLineEditor>("chat_box");
+
+ if (item == "can_cut")
+ {
+ return edit_box->canCut();
+ }
+ else if (item == "can_copy")
+ {
+ return edit_box->canCopy();
+ }
+ else if (item == "can_paste")
+ {
+ return edit_box->canPaste();
+ }
+ else if (item == "can_delete")
+ {
+ return edit_box->canDoDelete();
+ }
+ else if (item == "can_select_all")
+ {
+ return edit_box->canSelectAll();
+ }
+ return true;
+}
+
+
+void LLBottomTray::onContextMenuItemClicked(const LLSD& userdata)
+{
+ std::string item = userdata.asString();
+ LLLineEditor* edit_box = mNearbyChatBar->findChild<LLLineEditor>("chat_box");
+
+ if (item == "cut")
+ {
+ edit_box->cut();
+ }
+ else if (item == "copy")
+ {
+ edit_box->copy();
+ }
+ else if (item == "paste")
+ {
+ edit_box->paste();
+ }
+ else if (item == "delete")
+ {
+ edit_box->doDelete();
+ }
+ else if (item == "select_all")
+ {
+ edit_box->selectAll();
+ }
+}
+
void LLBottomTray::log(LLView* panel, const std::string& descr)
{
if (NULL == panel) return;
diff --git a/indra/newview/llbottomtray.h b/indra/newview/llbottomtray.h
index 7640cdcf9d..5d2ae2f199 100644
--- a/indra/newview/llbottomtray.h
+++ b/indra/newview/llbottomtray.h
@@ -174,6 +174,10 @@ protected:
static void* createNearbyChatBar(void* userdata);
+ void updateContextMenu(S32 x, S32 y, MASK mask);
+ void onContextMenuItemClicked(const LLSD& userdata);
+ bool onContextMenuItemEnabled(const LLSD& userdata);
+
/**
* Creates IM Chiclet based on session type (IM chat or Group chat)
*/
diff --git a/indra/newview/skins/default/xui/en/menu_bottomtray.xml b/indra/newview/skins/default/xui/en/menu_bottomtray.xml
index a7abb223ba..7ef91a1d85 100644
--- a/indra/newview/skins/default/xui/en/menu_bottomtray.xml
+++ b/indra/newview/skins/default/xui/en/menu_bottomtray.xml
@@ -52,4 +52,57 @@
function="CheckControl"
parameter="ShowSnapshotButton" />
</menu_item_check>
+ <menu_item_separator
+ name="Separator" />
+ <menu_item_call
+ label="Cut"
+ name="NearbyChatBar_Cut">
+ <menu_item_call.on_click
+ function="NearbyChatBar.Action"
+ parameter="cut" />
+ <menu_item_call.on_enable
+ function="NearbyChatBar.EnableMenuItem"
+ parameter="can_cut" />
+ </menu_item_call>
+ <menu_item_call
+ label="Copy"
+ name="NearbyChatBar_Copy">
+ <menu_item_call.on_click
+ function="NearbyChatBar.Action"
+ parameter="copy" />
+ <menu_item_call.on_enable
+ function="NearbyChatBar.EnableMenuItem"
+ parameter="can_copy" />
+ </menu_item_call>
+ <menu_item_call
+ label="Paste"
+ name="NearbyChatBar_Paste">
+ <menu_item_call.on_click
+ function="NearbyChatBar.Action"
+ parameter="paste" />
+ <menu_item_call.on_enable
+ function="NearbyChatBar.EnableMenuItem"
+ parameter="can_paste" />
+ </menu_item_call>
+ <menu_item_call
+ label="Delete"
+ name="NearbyChatBar_Delete">
+ <menu_item_call.on_click
+ function="NearbyChatBar.Action"
+ parameter="delete" />
+ <menu_item_call.on_enable
+ function="NearbyChatBar.EnableMenuItem"
+ parameter="can_delete" />
+ </menu_item_call>
+ <menu_item_call
+ label="Select All"
+ name="NearbyChatBar_Select_All">
+ <menu_item_call.on_click
+ function="NearbyChatBar.Action"
+ parameter="select_all" />
+ <menu_item_call.on_enable
+ function="NearbyChatBar.EnableMenuItem"
+ parameter="can_select_all" />
+ </menu_item_call>
+
</menu>