diff --git a/linden/indra/llui/lllineeditor.cpp b/linden/indra/llui/lllineeditor.cpp index 12d1929..0273225 100644 --- a/linden/indra/llui/lllineeditor.cpp +++ b/linden/indra/llui/lllineeditor.cpp @@ -53,6 +53,7 @@ #include "llui.h" #include "lluictrlfactory.h" #include "llclipboard.h" +#include "llmenugl.h" // // Imported globals @@ -80,6 +81,7 @@ const S32 PREEDIT_STANDOUT_POSITION = 2; const S32 PREEDIT_STANDOUT_THICKNESS = 2; static LLRegisterWidget r1("line_editor"); +LLLineEditor* LLLineEditor::sInstance = NULL; /* static */ LLPointer LLLineEditor::sImage; @@ -143,6 +145,25 @@ LLLineEditor::LLLineEditor(const std::string& name, const LLRect& rect, mHaveHistory = FALSE; // - reset current history line pointer mCurrentHistoryLine = 0; + // Right-click menu + + + LLMenuGL* menu; + menu = new LLMenuGL(std::string("popup")); + + menu->setCanTearOff(FALSE); + + + menu->append(new LLMenuItemCallGL(std::string("cut"), + handlePopup, NULL , (void*)0 ) ); + menu->append(new LLMenuItemCallGL(std::string("copy"), + handlePopup,NULL,(void*)1 ) ); + menu->append(new LLMenuItemCallGL(std::string("paste"), + handlePopup,NULL,(void*)2 ) ); + + menu->setVisible(FALSE); + addChild(menu); + mPopupMenuHandle = menu->getHandle(); if (font) { @@ -433,6 +454,26 @@ void LLLineEditor::selectAll() mIsSelecting = TRUE; } +void LLLineEditor::handlePopup(void* which) +{ + intptr_t action = (intptr_t)which; + + switch (action) + { + case 0: + LLLineEditor::sInstance->cut(); + break; + case 1: + LLLineEditor::sInstance->copy(); + break; + case 2: + LLLineEditor::sInstance->paste(); + break; + default: + break; + } +} + BOOL LLLineEditor::handleDoubleClick(S32 x, S32 y, MASK mask) { @@ -667,7 +708,28 @@ BOOL LLLineEditor::handleMouseUp(S32 x, S32 y, MASK mask) return handled; } +/* +BOOL LLLineEditor::handleRightMouseUp(S32 x, S32 y, MASK mask) +{ + //TODO: switch ToolTip on again + + return TRUE; +} +*/ +BOOL LLLineEditor::handleRightMouseDown(S32 x, S32 y, MASK mask) +{ + //TODO: switch ToolTip off; see above BOOL LLLineEditor::handleRightMouseUp + sInstance = this; + LLMenuGL* menu = (LLMenuGL*)mPopupMenuHandle.get(); + if (menu) + { + menu->buildDrawLabels(); + menu->updateParent(LLMenuGL::sMenuContainer); + LLMenuGL::showPopup(this, menu, x, y); + } + return TRUE; +} // Remove a single character from the text void LLLineEditor::removeChar() diff --git a/linden/indra/llui/lllineeditor.h b/linden/indra/llui/lllineeditor.h index 09a240b..d07e0e2 100644 --- a/linden/indra/llui/lllineeditor.h +++ b/linden/indra/llui/lllineeditor.h @@ -83,12 +83,15 @@ public: void setColorParameters(LLXMLNodePtr node); static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory); static void cleanupClass(); + static void handlePopup(void* which); + static LLLineEditor* sInstance; // mousehandler overrides /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleDoubleClick(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(); @@ -306,6 +309,8 @@ protected: std::vector mPreeditPositions; LLPreeditor::standouts_t mPreeditStandouts; + LLHandle mPopupMenuHandle; + private: // Utility on top of LLUI::getUIImage, looks up a named image in a given XML node and returns it if possible // or returns a given default image if anything in the process fails.