diff options
author | Ychebotarev ProductEngine <ychebotarev@productengine.com> | 2010-02-05 13:04:29 +0200 |
---|---|---|
committer | Ychebotarev ProductEngine <ychebotarev@productengine.com> | 2010-02-05 13:04:29 +0200 |
commit | a69a85544f628b7cd5a19f54a059eb02324419e4 (patch) | |
tree | b496d70a74983a14dc2a1189acf21c4cacdcf625 /indra/llui | |
parent | b79b8f87a37888decd3f82e9e255cce641a3955f (diff) | |
parent | 553cf40d136e70f4819cb2b72d0483287db81b17 (diff) |
merge
--HG--
branch : product-engine
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/lllineeditor.cpp | 42 | ||||
-rw-r--r-- | indra/llui/lllineeditor.h | 9 | ||||
-rw-r--r-- | indra/llui/lltexteditor.cpp | 8 | ||||
-rw-r--r-- | indra/llui/lltexteditor.h | 7 |
4 files changed, 60 insertions, 6 deletions
diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index eb2b4f7705..00376cc4dd 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -55,6 +55,7 @@ #include "llui.h" #include "lluictrlfactory.h" #include "llclipboard.h" +#include "llmenugl.h" // // Imported globals @@ -164,7 +165,8 @@ LLLineEditor::LLLineEditor(const LLLineEditor::Params& p) mTentativeFgColor(p.text_tentative_color()), mHighlightColor(p.highlight_color()), mPreeditBgColor(p.preedit_bg_color()), - mGLFont(p.font) + mGLFont(p.font), + mContextMenuHandle() { llassert( mMaxLengthBytes > 0 ); @@ -191,6 +193,12 @@ LLLineEditor::LLLineEditor(const LLLineEditor::Params& p) setCursor(mText.length()); setPrevalidate(p.prevalidate_callback()); + + LLContextMenu* menu = LLUICtrlFactory::instance().createFromFile<LLContextMenu> + ("menu_text_editor.xml", + LLMenuGL::sMenuContainer, + LLMenuHolderGL::child_registry_t::instance()); + setContextMenu(menu); } LLLineEditor::~LLLineEditor() @@ -663,6 +671,16 @@ BOOL LLLineEditor::handleMiddleMouseDown(S32 x, S32 y, MASK mask) return TRUE; } +BOOL LLLineEditor::handleRightMouseDown(S32 x, S32 y, MASK mask) +{ + setFocus(TRUE); + if (!LLUICtrl::handleRightMouseDown(x, y, mask)) + { + showContextMenu(x, y); + } + return TRUE; +} + BOOL LLLineEditor::handleHover(S32 x, S32 y, MASK mask) { BOOL handled = FALSE; @@ -2560,3 +2578,25 @@ LLWString LLLineEditor::getConvertedText() const } return text; } + +void LLLineEditor::showContextMenu(S32 x, S32 y) +{ + LLContextMenu* menu = static_cast<LLContextMenu*>(mContextMenuHandle.get()); + + if (menu) + { + gEditMenuHandler = this; + + S32 screen_x, screen_y; + localPointToScreen(x, y, &screen_x, &screen_y); + menu->show(screen_x, screen_y); + } +} + +void LLLineEditor::setContextMenu(LLContextMenu* new_context_menu) +{ + if (new_context_menu) + mContextMenuHandle = new_context_menu->getHandle(); + else + mContextMenuHandle.markDead(); +} diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index 49e9539b16..a06a317f76 100644 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -56,6 +56,7 @@ class LLFontGL; class LLLineEditorRollback; class LLButton; +class LLContextMenu; typedef boost::function<BOOL (const LLWString &wstr)> LLLinePrevalidateFunc; @@ -113,6 +114,7 @@ protected: LLLineEditor(const Params&); friend class LLUICtrlFactory; friend class LLFloaterEditUI; + void showContextMenu(S32 x, S32 y); public: virtual ~LLLineEditor(); @@ -122,6 +124,7 @@ public: /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleDoubleClick(S32 x,S32 y,MASK mask); /*virtual*/ BOOL handleMiddleMouseDown(S32 x,S32 y,MASK mask); + /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask ); /*virtual*/ BOOL handleUnicodeCharHere(llwchar uni_char); /*virtual*/ void onMouseCaptureLost(); @@ -249,7 +252,9 @@ public: void updateHistory(); // stores current line in history void setReplaceNewlinesWithSpaces(BOOL replace); - + + void setContextMenu(LLContextMenu* new_context_menu); + private: // private helper methods @@ -348,6 +353,8 @@ protected: std::vector<S32> mPreeditPositions; LLPreeditor::standouts_t mPreeditStandouts; + LLHandle<LLView> mContextMenuHandle; + private: // Instances that by default point to the statics but can be overidden in XML. LLPointer<LLUIImage> mBgImage; diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 3fdb48b3ca..ac5a0376fc 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -242,7 +242,8 @@ LLTextEditor::Params::Params() handle_edit_keys_directly("handle_edit_keys_directly", false), show_line_numbers("show_line_numbers", false), default_color("default_color"), - commit_on_focus_lost("commit_on_focus_lost", false) + commit_on_focus_lost("commit_on_focus_lost", false), + show_context_menu("show_context_menu") {} LLTextEditor::LLTextEditor(const LLTextEditor::Params& p) : @@ -258,7 +259,8 @@ LLTextEditor::LLTextEditor(const LLTextEditor::Params& p) : mMouseDownX(0), mMouseDownY(0), mTabsToNextField(p.ignore_tab), - mContextMenu(NULL) + mContextMenu(NULL), + mShowContextMenu(p.show_context_menu) { mDefaultFont = p.font; @@ -720,7 +722,7 @@ BOOL LLTextEditor::handleRightMouseDown(S32 x, S32 y, MASK mask) } if (!LLTextBase::handleRightMouseDown(x, y, mask)) { - if(getMouseOpaque()) + if(getChowContextMenu()) { showContextMenu(x, y); } diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index a136f9ccce..d96198d9ce 100644 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -68,7 +68,8 @@ public: ignore_tab, handle_edit_keys_directly, show_line_numbers, - commit_on_focus_lost; + commit_on_focus_lost, + show_context_menu; //colors Optional<LLUIColor> default_color; @@ -200,6 +201,9 @@ public: const LLTextSegmentPtr getPreviousSegment() const; void getSelectedSegments(segment_vec_t& segments) const; + void setShowContextMenu(bool show) { mShowContextMenu = show; } + bool getChowContextMenu() const { return mShowContextMenu; } + protected: void showContextMenu(S32 x, S32 y); void drawPreeditMarker(); @@ -319,6 +323,7 @@ private: BOOL mTakesFocus; BOOL mAllowEmbeddedItems; + bool mShowContextMenu; LLUUID mSourceID; |