diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index f2c5084be..5f0c224b5 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -52,6 +52,7 @@ #include "llcontrol.h" #include "llkeyboard.h" #include "llsdparam.h" +#include "llmenugl.h" static LLRegisterWidget r("scroll_list"); @@ -131,6 +132,7 @@ LLScrollListCtrl::LLScrollListCtrl(const std::string& name, const LLRect& rect, mHighlightedItem(-1), mBorder(NULL), mSortCallback(NULL), + mPopupMenu(NULL), mCommentTextView(NULL), mNumDynamicWidthColumns(0), mTotalStaticColumnWidth(0), @@ -1724,6 +1726,21 @@ BOOL LLScrollListCtrl::handleMouseUp(S32 x, S32 y, MASK mask) return LLUICtrl::handleMouseUp(x, y, mask); } +// virtual +BOOL LLScrollListCtrl::handleRightMouseDown(S32 x, S32 y, MASK mask) +{ + if (!mPopupMenu) return FALSE; // No menu, no bother + LLScrollListItem *item = hitItem(x, y); + if (item) + { + if (!item->getSelected()) selectItem(item); // Right click on unselected item is for that item only + mPopupMenu->buildDrawLabels(); + LLMenuGL::showPopup(this, mPopupMenu, x, y); + return TRUE; + } + return FALSE; +} + BOOL LLScrollListCtrl::handleDoubleClick(S32 x, S32 y, MASK mask) { //BOOL handled = FALSE; @@ -2565,6 +2582,14 @@ LLView* LLScrollListCtrl::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFac node->getAttributeString("tool_tip", tool_tip); scroll_list->setToolTip(tool_tip); + std::string menu_file; + if (node->getAttributeString("menu_file", menu_file)) + { + LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu(menu_file, LLMenuGL::sMenuContainer); + LLMenuGL::sMenuContainer->addChild(menu); + scroll_list->setContextMenu(menu); + } + LLSD columns; S32 index = 0; for (LLXMLNodePtr child = node->getFirstChild(); child.notNull(); child = child->getNextSibling()) diff --git a/indra/llui/llscrolllistctrl.h b/indra/llui/llscrolllistctrl.h index 27735f47a..9babab009 100644 --- a/indra/llui/llscrolllistctrl.h +++ b/indra/llui/llscrolllistctrl.h @@ -45,6 +45,8 @@ #include "llscrolllistitem.h" #include "llscrolllistcolumn.h" +class LLMenuGL; + class LLScrollListCtrl : public LLUICtrl, public LLEditMenuHandler, public LLCtrlListInterface, public LLCtrlScrollInterface { @@ -247,10 +249,14 @@ public: void clearSearchString() { mSearchString.clear(); } + // support right-click context menus for avatar/group lists + void setContextMenu(LLMenuGL* menu) { mPopupMenu = menu; } + // Overridden from LLView /*virtual*/ void draw(); /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask); + /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask); @@ -431,6 +437,7 @@ private: S32 mHighlightedItem; class LLViewBorder* mBorder; + LLMenuGL *mPopupMenu; LLView *mCommentTextView;