diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-08 16:28:44 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-08 16:28:44 +0000 |
commit | 0e0e6d757d44f0b0a3678a714c0c09186e3aa6eb (patch) | |
tree | a2bcf52eaa02b828865954b6fb800fccee08463b /views/controls/button | |
parent | b57c599f4d27dbd93db10033d599fbb512611788 (diff) | |
download | chromium_src-0e0e6d757d44f0b0a3678a714c0c09186e3aa6eb.zip chromium_src-0e0e6d757d44f0b0a3678a714c0c09186e3aa6eb.tar.gz chromium_src-0e0e6d757d44f0b0a3678a714c0c09186e3aa6eb.tar.bz2 |
Enabling the default button behavior on Linux toolkit_views.
I had to make the KeyEvent constructor include the event flags.
Also cleaned-up some unit-tests
BUG=None
TEST=Run the unit-tests.
Review URL: http://codereview.chromium.org/266012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28397 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/button')
-rw-r--r-- | views/controls/button/custom_button.cc | 14 | ||||
-rw-r--r-- | views/controls/button/native_button_gtk.cc | 7 |
2 files changed, 8 insertions, 13 deletions
diff --git a/views/controls/button/custom_button.cc b/views/controls/button/custom_button.cc index 67ee098..91bc33c 100644 --- a/views/controls/button/custom_button.cc +++ b/views/controls/button/custom_button.cc @@ -94,18 +94,8 @@ bool CustomButton::IsTriggerableEvent(const MouseEvent& e) { bool CustomButton::AcceleratorPressed(const Accelerator& accelerator) { if (enabled_) { SetState(BS_NORMAL); -#if defined(OS_WIN) - KeyEvent key_event(Event::ET_KEY_RELEASED, accelerator.GetKeyCode(), 0, 0); -#elif defined(OS_LINUX) - GdkEventKey gdk_key; - memset(&gdk_key, 0, sizeof(GdkEventKey)); - gdk_key.type = GDK_KEY_RELEASE; - gdk_key.keyval = accelerator.GetKeyCode(); - gdk_key.state = (accelerator.IsAltDown() << 3) + - (accelerator.IsCtrlDown() << 2) + - accelerator.IsShiftDown(); - KeyEvent key_event(&gdk_key); -#endif + KeyEvent key_event(Event::ET_KEY_RELEASED, accelerator.GetKeyCode(), + accelerator.modifiers(), 0, 0); NotifyClick(key_event); return true; } diff --git a/views/controls/button/native_button_gtk.cc b/views/controls/button/native_button_gtk.cc index fd58c42..17a25e2 100644 --- a/views/controls/button/native_button_gtk.cc +++ b/views/controls/button/native_button_gtk.cc @@ -55,7 +55,8 @@ void NativeButtonGtk::UpdateEnabled() { void NativeButtonGtk::UpdateDefault() { if (!native_view()) return; - NOTIMPLEMENTED(); + if (native_button_->is_default()) + gtk_widget_grab_default(native_view()); } View* NativeButtonGtk::GetView() { @@ -96,6 +97,10 @@ void NativeButtonGtk::CreateNativeControl() { GtkWidget* widget = gtk_button_new(); g_signal_connect(G_OBJECT(widget), "clicked", G_CALLBACK(CallClicked), this); + + // Any push button can become the default button. + GTK_WIDGET_SET_FLAGS(widget, GTK_CAN_DEFAULT); + NativeControlCreated(widget); } |