summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-09 23:42:35 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-09 23:42:35 +0000
commit54f0b8af290a09d00fc6b888c14f7a21dbecce7a (patch)
treee2eb35c52019a09345971df865f4b57d6d4cc548 /views
parent4ed536fb5831c7ff6c5d2cacaf5182bf9f00af70 (diff)
downloadchromium_src-54f0b8af290a09d00fc6b888c14f7a21dbecce7a.zip
chromium_src-54f0b8af290a09d00fc6b888c14f7a21dbecce7a.tar.gz
chromium_src-54f0b8af290a09d00fc6b888c14f7a21dbecce7a.tar.bz2
The textfield's text was not updated when text is updated by input.
BUG=None TEST=view_examples now has button to show & update textfield's text. Review URL: http://codereview.chromium.org/267040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28629 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/controls/textfield/native_textfield_gtk.cc1
-rw-r--r--views/examples/textfield_example.h32
2 files changed, 29 insertions, 4 deletions
diff --git a/views/controls/textfield/native_textfield_gtk.cc b/views/controls/textfield/native_textfield_gtk.cc
index 9704e7e..7a4c49a 100644
--- a/views/controls/textfield/native_textfield_gtk.cc
+++ b/views/controls/textfield/native_textfield_gtk.cc
@@ -220,6 +220,7 @@ gboolean NativeTextfieldGtk::OnChangedHandler(
}
gboolean NativeTextfieldGtk::OnChanged() {
+ textfield_->SyncText();
Textfield::Controller* controller = textfield_->GetController();
if (controller)
controller->ContentsChanged(textfield_, GetText());
diff --git a/views/examples/textfield_example.h b/views/examples/textfield_example.h
index 75e3e7f..ec7c625 100644
--- a/views/examples/textfield_example.h
+++ b/views/examples/textfield_example.h
@@ -6,6 +6,7 @@
#define VIEWS_EXAMPLES_TEXTFIELD_EXAMPLE_H_
#include "base/string_util.h"
+#include "views/controls/button/text_button.h"
#include "views/controls/label.h"
#include "views/controls/tabbed_pane/tabbed_pane.h"
#include "views/controls/textfield/textfield.h"
@@ -17,12 +18,15 @@ using views::Textfield;
// TextfieldExample mimics login screen.
class TextfieldExample : protected ExampleBase,
- public Textfield::Controller {
+ private Textfield::Controller,
+ private views::ButtonListener {
public:
TextfieldExample(views::TabbedPane* tabbed_pane, views::Label* message)
: ExampleBase(message),
name_(new Textfield()),
- password_(new Textfield(Textfield::STYLE_PASSWORD)) {
+ password_(new Textfield(Textfield::STYLE_PASSWORD)),
+ show_password_(new views::TextButton(this, L"Show password")),
+ clear_all_(new views::TextButton(this, L"Clear All")) {
name_->SetController(this);
password_->SetController(this);
@@ -42,6 +46,10 @@ class TextfieldExample : protected ExampleBase,
layout->StartRow(0, 0);
layout->AddView(new views::Label(L"Password:"));
layout->AddView(password_);
+ layout->StartRow(0, 0);
+ layout->AddView(show_password_);
+ layout->StartRow(0, 0);
+ layout->AddView(clear_all_);
}
virtual ~TextfieldExample() {}
@@ -64,8 +72,25 @@ class TextfieldExample : protected ExampleBase,
return false;
}
+ // ButtonListner implementation.
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event) {
+ if (sender == show_password_) {
+ PrintStatus(L"Password [%ls]",
+ UTF16ToWideHack(password_->text()).c_str());
+ } else if (sender == clear_all_) {
+ string16 empty;
+ name_->SetText(empty);
+ password_->SetText(empty);
+ }
+ }
+
// Textfields for name and password.
- views::Textfield* name_, *password_;
+ views::Textfield* name_;
+ views::Textfield* password_;
+
+ // Buttons to show password text and to clear the textfields.
+ views::TextButton* show_password_;
+ views::TextButton* clear_all_;
DISALLOW_COPY_AND_ASSIGN(TextfieldExample);
};
@@ -73,4 +98,3 @@ class TextfieldExample : protected ExampleBase,
} // namespace examples
#endif // VIEWS_EXAMPLES_TEXTFIELD_EXAMPLE_H_
-