diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-08 01:13:25 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-08 01:13:25 +0000 |
commit | e8e0f3691a410d6de40bfff021b0da33425f36cb (patch) | |
tree | eba7275ce7aac42fb014896f2b65a09026c0499c /chrome/views/native_button.cc | |
parent | 4adc70599db32d760184ec908f11c7d000b6b79c (diff) | |
download | chromium_src-e8e0f3691a410d6de40bfff021b0da33425f36cb.zip chromium_src-e8e0f3691a410d6de40bfff021b0da33425f36cb.tar.gz chromium_src-e8e0f3691a410d6de40bfff021b0da33425f36cb.tar.bz2 |
In dialogs, when the focus moves to a button, that button should become the default button.
When the focus is not a button, then the default button should be the one the delegate specifies.
BUG=4132
TEST=Open the option dialog. OK should be the default and focused button. Move the focus around by pressing tab. When a button is selected, it should be the default button.
Review URL: http://codereview.chromium.org/10230
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5056 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views/native_button.cc')
-rw-r--r-- | chrome/views/native_button.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/chrome/views/native_button.cc b/chrome/views/native_button.cc index bbee9e9..00aea52 100644 --- a/chrome/views/native_button.cc +++ b/chrome/views/native_button.cc @@ -12,6 +12,8 @@ namespace views { +const char NativeButton::kViewClassName[] = "chrome/views/NativeButton"; + NativeButton::NativeButton(const std::wstring& label) : enforce_dlu_min_size_(true) { Init(label, false); @@ -25,6 +27,10 @@ NativeButton::NativeButton(const std::wstring& label, bool is_default) NativeButton::~NativeButton() { } +std::string NativeButton::GetClassName() const { + return kViewClassName; +} + void NativeButton::SetListener(Listener *l) { listener_ = l; } @@ -116,6 +122,18 @@ void NativeButton::ConfigureNativeButton(HWND hwnd) { ::SetWindowText(hwnd, label_.c_str()); } +void NativeButton::SetDefaultButton(bool is_default_button) { + if (is_default_button == is_default_) + return; + is_default_ = is_default_button; + if (is_default_button) + AddAccelerator(Accelerator(VK_RETURN, false, false, false)); + else + RemoveAccelerator(Accelerator(VK_RETURN, false, false, false)); + SendMessage(GetNativeControlHWND(), BM_SETSTYLE, + is_default_button ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON, true); +} + bool NativeButton::AcceleratorPressed(const Accelerator& accelerator) { if (enabled_) { Clicked(); |