diff options
Diffstat (limited to 'chrome/views')
-rw-r--r-- | chrome/views/text_field.cc | 14 | ||||
-rw-r--r-- | chrome/views/text_field.h | 5 |
2 files changed, 18 insertions, 1 deletions
diff --git a/chrome/views/text_field.cc b/chrome/views/text_field.cc index 62ebdc8..79ee7b9 100644 --- a/chrome/views/text_field.cc +++ b/chrome/views/text_field.cc @@ -47,6 +47,7 @@ class TextField::Edit std::wstring GetText() const; void SetText(const std::wstring& text); + void AppendText(const std::wstring& text); std::wstring GetSelectedText() const; @@ -315,6 +316,13 @@ void TextField::Edit::SetText(const std::wstring& text) { SetWindowText(text_to_set.c_str()); } +void TextField::Edit::AppendText(const std::wstring& text) { + int text_length = GetWindowTextLength(); + ::SendMessage(m_hWnd, TBM_SETSEL, true, MAKELPARAM(text_length, text_length)); + ::SendMessage(m_hWnd, EM_REPLACESEL, false, + reinterpret_cast<LPARAM>(text.c_str())); +} + std::wstring TextField::Edit::GetSelectedText() const { // Figure out the length of the selection. long start; @@ -953,6 +961,12 @@ void TextField::SetText(const std::wstring& text) { edit_->SetText(text); } +void TextField::AppendText(const std::wstring& text) { + text_ += text; + if (edit_) + edit_->AppendText(text); +} + void TextField::CalculateInsets(gfx::Insets* insets) { DCHECK(insets); diff --git a/chrome/views/text_field.h b/chrome/views/text_field.h index 4fa876c..9fe0347 100644 --- a/chrome/views/text_field.h +++ b/chrome/views/text_field.h @@ -97,9 +97,12 @@ class TextField : public View { // Returns the text currently displayed in the text field. std::wstring GetText() const; - // Set the text currently displayed in the text field. + // Sets the text currently displayed in the text field. void SetText(const std::wstring& text); + // Appends the given string to the previously-existing text in the field. + void AppendText(const std::wstring& text); + virtual void Focus(); // Causes the edit field to be fully selected. |