diff options
author | thickbrick | 2010-09-25 15:00:50 +0200 |
---|---|---|
committer | thickbrick | 2010-09-25 15:00:50 +0200 |
commit | 81a3df503aece6b46e1efbdb7e274253cb898660 (patch) | |
tree | c3a56c38f8ba0ac051a7ced0d033d87f69b3c71c /linden/indra/llui | |
parent | LLLineEditor context translator: (diff) | |
download | meta-impy-81a3df503aece6b46e1efbdb7e274253cb898660.zip meta-impy-81a3df503aece6b46e1efbdb7e274253cb898660.tar.gz meta-impy-81a3df503aece6b46e1efbdb7e274253cb898660.tar.bz2 meta-impy-81a3df503aece6b46e1efbdb7e274253cb898660.tar.xz |
LLTextEditor 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 'linden/indra/llui')
-rw-r--r-- | linden/indra/llui/lltexteditor.cpp | 34 | ||||
-rw-r--r-- | linden/indra/llui/lltexteditor.h | 1 |
2 files changed, 16 insertions, 19 deletions
diff --git a/linden/indra/llui/lltexteditor.cpp b/linden/indra/llui/lltexteditor.cpp index 4bae155..adf0260 100644 --- a/linden/indra/llui/lltexteditor.cpp +++ b/linden/indra/llui/lltexteditor.cpp | |||
@@ -330,7 +330,8 @@ LLTextEditor::LLTextEditor( | |||
330 | mReflowNeeded(FALSE), | 330 | mReflowNeeded(FALSE), |
331 | mScrollNeeded(FALSE), | 331 | mScrollNeeded(FALSE), |
332 | mSpellCheckable(FALSE), | 332 | mSpellCheckable(FALSE), |
333 | mShowMisspellings(FALSE) | 333 | mShowMisspellings(FALSE), |
334 | mAllowTranslate(FALSE) | ||
334 | { | 335 | { |
335 | mSourceID.generate(); | 336 | mSourceID.generate(); |
336 | 337 | ||
@@ -1484,7 +1485,8 @@ BOOL LLTextEditor::handleRightMouseDown( S32 x, S32 y, MASK mask ) | |||
1484 | 1485 | ||
1485 | //setCursorAtLocalPos( x, y, TRUE ); | 1486 | //setCursorAtLocalPos( x, y, TRUE ); |
1486 | S32 wordStart = 0; | 1487 | S32 wordStart = 0; |
1487 | S32 wordEnd = getCursorPosFromLocalCoord(x,y,TRUE); | 1488 | S32 wordEnd = 0; |
1489 | S32 pos = getCursorPosFromLocalCoord(x,y,TRUE); | ||
1488 | 1490 | ||
1489 | LLMenuGL* menu = (LLMenuGL*)mPopupMenuHandle.get(); | 1491 | LLMenuGL* menu = (LLMenuGL*)mPopupMenuHandle.get(); |
1490 | if (menu) | 1492 | if (menu) |
@@ -1503,29 +1505,21 @@ BOOL LLTextEditor::handleRightMouseDown( S32 x, S32 y, MASK mask ) | |||
1503 | } | 1505 | } |
1504 | suggestionMenuItems.clear(); | 1506 | suggestionMenuItems.clear(); |
1505 | 1507 | ||
1506 | menu->setItemVisible("Translate To", !mReadOnly); | 1508 | bool is_word_part = getWordBoundriesAt(pos, &wordStart, &wordEnd); |
1507 | menu->setItemVisible("Transep", !mReadOnly); | 1509 | |
1510 | // allow_translate="true" in xui | ||
1511 | bool can_translate = mAllowTranslate && !mReadOnly && (is_word_part || hasSelection()); | ||
1512 | menu->setItemVisible("Translate To", can_translate); | ||
1513 | menu->setItemVisible("Transep", can_translate); | ||
1508 | 1514 | ||
1509 | // spell_check="true" in xui | 1515 | // spell_check="true" in xui |
1510 | if (!mReadOnly && mSpellCheckable) | 1516 | if (!mReadOnly && mSpellCheckable) |
1511 | { | 1517 | { |
1512 | const LLWString &text = mWText; | 1518 | if (is_word_part) |
1513 | |||
1514 | if (isPartOfWord(text[wordEnd]) && !mReadOnly) | ||
1515 | { | 1519 | { |
1516 | // Select word the cursor is over | 1520 | const LLWString &text = mWText; |
1517 | while ((wordEnd > 0) && isPartOfWord(text[wordEnd-1])) | ||
1518 | { | ||
1519 | wordEnd--; | ||
1520 | } | ||
1521 | wordStart = wordEnd; | ||
1522 | //startSelection(); | ||
1523 | |||
1524 | while ((wordEnd < (S32)text.length()) && isPartOfWord( text[wordEnd] ) ) | ||
1525 | { | ||
1526 | wordEnd++; | ||
1527 | } | ||
1528 | std::string selectedWord(std::string(text.begin(), text.end()).substr(wordStart,wordEnd-wordStart)); | 1521 | std::string selectedWord(std::string(text.begin(), text.end()).substr(wordStart,wordEnd-wordStart)); |
1522 | |||
1529 | if (!glggHunSpell->isSpelledRight(selectedWord)) | 1523 | if (!glggHunSpell->isSpelledRight(selectedWord)) |
1530 | { | 1524 | { |
1531 | //misspelled word here, and you have just right clicked on it! | 1525 | //misspelled word here, and you have just right clicked on it! |
@@ -4964,6 +4958,8 @@ void LLTextEditor::setTextEditorParameters(LLXMLNodePtr node) | |||
4964 | 4958 | ||
4965 | node->getAttributeBOOL("spell_check", mSpellCheckable); | 4959 | node->getAttributeBOOL("spell_check", mSpellCheckable); |
4966 | 4960 | ||
4961 | node->getAttributeBOOL("allow_translate", mAllowTranslate); | ||
4962 | |||
4967 | LLColor4 color; | 4963 | LLColor4 color; |
4968 | if (LLUICtrlFactory::getAttributeColor(node,"cursor_color", color)) | 4964 | if (LLUICtrlFactory::getAttributeColor(node,"cursor_color", color)) |
4969 | { | 4965 | { |
diff --git a/linden/indra/llui/lltexteditor.h b/linden/indra/llui/lltexteditor.h index f6669c4..3269e17 100644 --- a/linden/indra/llui/lltexteditor.h +++ b/linden/indra/llui/lltexteditor.h | |||
@@ -530,6 +530,7 @@ private: | |||
530 | std::vector<S32> misspellLocations; // where all the mispelled words are | 530 | std::vector<S32> misspellLocations; // where all the mispelled words are |
531 | BOOL mSpellCheckable; // set in xui as "spell_check". Default value for a field | 531 | BOOL mSpellCheckable; // set in xui as "spell_check". Default value for a field |
532 | BOOL mShowMisspellings; // show misspellings as highlighted (initialized in the ctor) | 532 | BOOL mShowMisspellings; // show misspellings as highlighted (initialized in the ctor) |
533 | BOOL mAllowTranslate; // set in xui as "allow_translate". | ||
533 | 534 | ||
534 | S32 mMaxTextByteLength; // Maximum length mText is allowed to be in bytes | 535 | S32 mMaxTextByteLength; // Maximum length mText is allowed to be in bytes |
535 | 536 | ||