diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-09 23:42:35 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-09 23:42:35 +0000 |
commit | 54f0b8af290a09d00fc6b888c14f7a21dbecce7a (patch) | |
tree | e2eb35c52019a09345971df865f4b57d6d4cc548 /views/examples | |
parent | 4ed536fb5831c7ff6c5d2cacaf5182bf9f00af70 (diff) | |
download | chromium_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/examples')
-rw-r--r-- | views/examples/textfield_example.h | 32 |
1 files changed, 28 insertions, 4 deletions
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_ - |