Address Issue 352: Ctrl-Backspace in editable text fields
This commit is contained in:
@@ -1814,6 +1814,33 @@ void LLTextEditor::removeChar()
|
||||
}
|
||||
}
|
||||
|
||||
// Remove a word (set of characters up to next space/punctuation) from the text
|
||||
void LLTextEditor::removeWord(bool prev)
|
||||
{
|
||||
const U32 pos(mCursorPos);
|
||||
if (prev ? pos > 0 : static_cast<S32>(pos) < getLength())
|
||||
{
|
||||
U32 new_pos(prev ? prevWordPos(pos) : nextWordPos(pos));
|
||||
if (new_pos == pos) // Other character we don't jump over
|
||||
new_pos = prev ? prevWordPos(new_pos-1) : nextWordPos(new_pos+1);
|
||||
|
||||
const U32 diff(labs(pos - new_pos));
|
||||
if (prev)
|
||||
{
|
||||
remove(new_pos, diff, false);
|
||||
setCursorPos(new_pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
remove(pos, diff, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
reportBadKeystroke();
|
||||
}
|
||||
}
|
||||
|
||||
// Add a single character to the text
|
||||
S32 LLTextEditor::addChar(S32 pos, llwchar wc)
|
||||
{
|
||||
@@ -2447,7 +2474,10 @@ BOOL LLTextEditor::handleSpecialKey(const KEY key, const MASK mask, BOOL* return
|
||||
else
|
||||
if( 0 < mCursorPos )
|
||||
{
|
||||
removeCharOrTab();
|
||||
if (mask == MASK_CONTROL)
|
||||
removeWord(true);
|
||||
else
|
||||
removeCharOrTab();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2455,6 +2485,12 @@ BOOL LLTextEditor::handleSpecialKey(const KEY key, const MASK mask, BOOL* return
|
||||
}
|
||||
break;
|
||||
|
||||
case KEY_DELETE:
|
||||
if (getEnabled() && mask == MASK_CONTROL)
|
||||
{
|
||||
removeWord(false);
|
||||
}
|
||||
break;
|
||||
|
||||
case KEY_RETURN:
|
||||
if (mask == MASK_NONE)
|
||||
|
||||
Reference in New Issue
Block a user