diff options
author | thickbrick | 2010-09-25 12:58:56 +0200 |
---|---|---|
committer | thickbrick | 2010-09-25 13:35:23 +0200 |
commit | f5006e8a2f34afa390f0bbcf0f6af15218cf4105 (patch) | |
tree | 86c347d0f698afa71a7ffe6dec493e386ecdcb8f /linden/indra/llui/lllineeditor.cpp | |
parent | LLLineEditor context translator: re-select text properly. (diff) | |
download | meta-impy-f5006e8a2f34afa390f0bbcf0f6af15218cf4105.zip meta-impy-f5006e8a2f34afa390f0bbcf0f6af15218cf4105.tar.gz meta-impy-f5006e8a2f34afa390f0bbcf0f6af15218cf4105.tar.bz2 meta-impy-f5006e8a2f34afa390f0bbcf0f6af15218cf4105.tar.xz |
LLLineEditor context translator:
- Added a xui attribute "allow_translate", default to off (not enabled
in any xml file yet.)
- Only show translate menu if clicked on a word, or something is selected.
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llui/lllineeditor.cpp | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/linden/indra/llui/lllineeditor.cpp b/linden/indra/llui/lllineeditor.cpp index 503a1bd..05966d6 100644 --- a/linden/indra/llui/lllineeditor.cpp +++ b/linden/indra/llui/lllineeditor.cpp | |||
@@ -175,7 +175,8 @@ LLLineEditor::LLLineEditor(const std::string& name, const LLRect& rect, | |||
175 | mImage( sImage ), | 175 | mImage( sImage ), |
176 | mReplaceNewlinesWithSpaces( TRUE ), | 176 | mReplaceNewlinesWithSpaces( TRUE ), |
177 | mSpellCheckable( FALSE ), | 177 | mSpellCheckable( FALSE ), |
178 | mShowMisspellings(FALSE) | 178 | mShowMisspellings(FALSE), |
179 | mAllowTranslate(FALSE) | ||
179 | { | 180 | { |
180 | llassert( max_length_bytes > 0 ); | 181 | llassert( max_length_bytes > 0 ); |
181 | 182 | ||
@@ -762,7 +763,8 @@ BOOL LLLineEditor::handleRightMouseDown( S32 x, S32 y, MASK mask ) | |||
762 | 763 | ||
763 | //setCursorAtLocalPos( x); | 764 | //setCursorAtLocalPos( x); |
764 | S32 wordStart = 0; | 765 | S32 wordStart = 0; |
765 | S32 wordEnd = calculateCursorFromMouse(x); | 766 | S32 wordEnd = 0; |
767 | S32 pos = calculateCursorFromMouse(x); | ||
766 | 768 | ||
767 | LLMenuGL* menu = (LLMenuGL*)mPopupMenuHandle.get(); | 769 | LLMenuGL* menu = (LLMenuGL*)mPopupMenuHandle.get(); |
768 | if (menu) | 770 | if (menu) |
@@ -785,29 +787,19 @@ BOOL LLLineEditor::handleRightMouseDown( S32 x, S32 y, MASK mask ) | |||
785 | } | 787 | } |
786 | suggestionMenuItems.clear(); | 788 | suggestionMenuItems.clear(); |
787 | 789 | ||
788 | menu->setItemVisible("Translate To", !mReadOnly); | 790 | bool is_word_part = getWordBoundriesAt(pos, &wordStart, &wordEnd); |
789 | menu->setItemVisible("Transep", !mReadOnly); | 791 | // allow_translate="true" in xui |
792 | bool can_translate = mAllowTranslate && !mReadOnly && (is_word_part || hasSelection()); | ||
793 | menu->setItemVisible("Translate To", can_translate); | ||
794 | menu->setItemVisible("Transep", can_translate); | ||
790 | 795 | ||
791 | // spell_check="true" in xui | 796 | // spell_check="true" in xui |
792 | if (!mReadOnly && mSpellCheckable) | 797 | if (!mReadOnly && mSpellCheckable) |
793 | { | 798 | { |
794 | const LLWString& text = mText.getWString(); | ||
795 | |||
796 | // search for word matches | 799 | // search for word matches |
797 | if (LLTextEditor::isPartOfWord(text[wordEnd])) | 800 | if (is_word_part) |
798 | { | 801 | { |
799 | // Select word the cursor is over | 802 | const LLWString& text = mText.getWString(); |
800 | while ((wordEnd > 0) && LLTextEditor::isPartOfWord(text[wordEnd-1])) | ||
801 | { | ||
802 | wordEnd--; | ||
803 | } | ||
804 | wordStart = wordEnd; | ||
805 | //startSelection(); | ||
806 | |||
807 | while ((wordEnd < (S32)text.length()) && LLTextEditor::isPartOfWord( text[wordEnd] ) ) | ||
808 | { | ||
809 | wordEnd++; | ||
810 | } | ||
811 | std::string selectedWord(std::string(text.begin(), text.end()).substr(wordStart,wordEnd-wordStart)); | 803 | std::string selectedWord(std::string(text.begin(), text.end()).substr(wordStart,wordEnd-wordStart)); |
812 | 804 | ||
813 | if (!glggHunSpell->isSpelledRight(selectedWord)) | 805 | if (!glggHunSpell->isSpelledRight(selectedWord)) |
@@ -2893,6 +2885,11 @@ LLView* LLLineEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory | |||
2893 | { | 2885 | { |
2894 | line_editor->setSpellCheckable(spell_checking); | 2886 | line_editor->setSpellCheckable(spell_checking); |
2895 | } | 2887 | } |
2888 | BOOL allow_translate = FALSE; | ||
2889 | if (node->getAttributeBOOL("allow_translate", allow_translate)) | ||
2890 | { | ||
2891 | line_editor->setAllowTranslate(allow_translate); | ||
2892 | } | ||
2896 | 2893 | ||
2897 | line_editor->setColorParameters(node); | 2894 | line_editor->setColorParameters(node); |
2898 | 2895 | ||