Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(463)

Unified Diff: ui/views/controls/textfield/native_textfield_win.cc

Issue 10693160: Add and specify Views::Textfield::SelectAll |reversed| flag, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove redundant comments. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/textfield/native_textfield_win.cc
diff --git a/ui/views/controls/textfield/native_textfield_win.cc b/ui/views/controls/textfield/native_textfield_win.cc
index ec9813210a5a55dd3c99d6b0b6d43bf95938b69c..5372cbc77e1a284480570b93a0b40380a4fb7b87 100644
--- a/ui/views/controls/textfield/native_textfield_win.cc
+++ b/ui/views/controls/textfield/native_textfield_win.cc
@@ -219,10 +219,11 @@ string16 NativeTextfieldWin::GetSelectedText() const {
return str;
}
-void NativeTextfieldWin::SelectAll() {
- // Select from the end to the front so that the first part of the text is
- // always visible.
- SetSel(GetTextLength(), 0);
+void NativeTextfieldWin::SelectAll(bool reversed) {
+ if (reversed)
+ SetSel(GetTextLength(), 0);
+ else
+ SetSel(0, GetTextLength());
}
void NativeTextfieldWin::ClearSelection() {
@@ -449,12 +450,12 @@ void NativeTextfieldWin::ExecuteCommand(int command_id) {
ScopedFreeze freeze(this, GetTextObjectModel());
OnBeforePossibleChange();
switch (command_id) {
- case IDS_APP_UNDO: Undo(); break;
- case IDS_APP_CUT: Cut(); break;
- case IDS_APP_COPY: Copy(); break;
- case IDS_APP_PASTE: Paste(); break;
- case IDS_APP_SELECT_ALL: SelectAll(); break;
- default: NOTREACHED(); break;
+ case IDS_APP_UNDO: Undo(); break;
+ case IDS_APP_CUT: Cut(); break;
+ case IDS_APP_COPY: Copy(); break;
+ case IDS_APP_PASTE: Paste(); break;
+ case IDS_APP_SELECT_ALL: SelectAll(false); break;
+ default: NOTREACHED(); break;
}
OnAfterPossibleChange(true);
}
@@ -1095,7 +1096,7 @@ void NativeTextfieldWin::OnAfterPossibleChange(bool should_redraw_text) {
string16 text(GetText());
ScopedSuspendUndo suspend_undo(GetTextObjectModel());
- SelectAll();
+ SelectAll(true);
ReplaceSel(reinterpret_cast<LPCTSTR>(text.c_str()), true);
SetSel(original_sel);
}
« no previous file with comments | « ui/views/controls/textfield/native_textfield_win.h ('k') | ui/views/controls/textfield/native_textfield_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698