summaryrefslogtreecommitdiffstats
path: root/views/controls
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-01 15:57:26 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-01 15:57:26 +0000
commit7f14e1fd31ddd510b19e2d9f6942c45435c9a8c6 (patch)
tree33fa783fff0459a26f38979a80c1e8b9aac8cad2 /views/controls
parent32a54416beeeda33978af7816f4135bf7dfa7e95 (diff)
downloadchromium_src-7f14e1fd31ddd510b19e2d9f6942c45435c9a8c6.zip
chromium_src-7f14e1fd31ddd510b19e2d9f6942c45435c9a8c6.tar.gz
chromium_src-7f14e1fd31ddd510b19e2d9f6942c45435c9a8c6.tar.bz2
Relanding focus traversal on Linux toolkit views.
It was previously breaking the interactive UI tests. That was because I changed the button base class to be focusable by default which led to many button beings added to the tab traversal order. I now explicitly make these buttons non focusable. Also because of the way we clear the native focus on Gtk (by setting focus to NULL on the top level window), views now default to clearing the focus when focused (so that views non backed by a native window don't leave the native focus on the previously native window). On Windows we used to focus the WidgetWin's HWND, and now we focus the top-level HWND. The WidgetWin class had to be changed to forward the key events to the root view that contains the focused view because of that. (otherwise it would send it to the top-level root-view, and if the focused view was in a child root-view it would not recieve the keyboard messages). Note that the mouse wheel does not need that, as the mouse-wheel Windows messages are sent to the HWND under the cursor. See: http://codereview.chromium.org/246030/show TEST=Run the tests BUG=NONE Review URL: http://codereview.chromium.org/255008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27723 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls')
-rw-r--r--views/controls/button/custom_button.h3
-rw-r--r--views/controls/button/image_button.h5
-rw-r--r--views/controls/button/text_button.cc1
-rw-r--r--views/controls/button/text_button.h4
-rw-r--r--views/controls/tabbed_pane/native_tabbed_pane_gtk.cc15
-rw-r--r--views/controls/tabbed_pane/native_tabbed_pane_gtk.h7
6 files changed, 34 insertions, 1 deletions
diff --git a/views/controls/button/custom_button.h b/views/controls/button/custom_button.h
index bd43d4d..f5b5cbe 100644
--- a/views/controls/button/custom_button.h
+++ b/views/controls/button/custom_button.h
@@ -14,6 +14,9 @@ namespace views {
// A button with custom rendering. The common base class of ImageButton and
// TextButton.
+// Note that this type of button is not focusable by default and will not be
+// part of the focus chain. Call SetFocusable(true) to make it part of the
+// focus chain.
class CustomButton : public Button,
public AnimationDelegate {
public:
diff --git a/views/controls/button/image_button.h b/views/controls/button/image_button.h
index 716a67e..654c4a0 100644
--- a/views/controls/button/image_button.h
+++ b/views/controls/button/image_button.h
@@ -11,6 +11,11 @@
namespace views {
// An image button.
+
+// Note that this type of button is not focusable by default and will not be
+// part of the focus chain. Call SetFocusable(true) to make it part of the
+// focus chain.
+
class ImageButton : public CustomButton {
public:
explicit ImageButton(ButtonListener* listener);
diff --git a/views/controls/button/text_button.cc b/views/controls/button/text_button.cc
index b5733c0..6bb3bec 100644
--- a/views/controls/button/text_button.cc
+++ b/views/controls/button/text_button.cc
@@ -330,6 +330,7 @@ void TextButton::SetEnabled(bool enabled) {
}
bool TextButton::OnMousePressed(const MouseEvent& e) {
+ RequestFocus();
return true;
}
diff --git a/views/controls/button/text_button.h b/views/controls/button/text_button.h
index 3fbc2b4..bd2fcb69 100644
--- a/views/controls/button/text_button.h
+++ b/views/controls/button/text_button.h
@@ -20,6 +20,10 @@ namespace views {
// A Border subclass that paints a TextButton's background layer -
// basically the button frame in the hot/pushed states.
//
+// Note that this type of button is not focusable by default and will not be
+// part of the focus chain. Call SetFocusable(true) to make it part of the
+// focus chain.
+//
////////////////////////////////////////////////////////////////////////////////
class TextButtonBorder : public Border {
public:
diff --git a/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc b/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc
index 6516c42..96e26df 100644
--- a/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc
+++ b/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc
@@ -119,6 +119,13 @@ void NativeTabbedPaneGtk::CreateNativeControl() {
}
////////////////////////////////////////////////////////////////////////////////
+// NativeTabbedPaneGtk, View override:
+
+FocusTraversable* NativeTabbedPaneGtk::GetFocusTraversable() {
+ return GetWidgetAt(GetSelectedTabIndex());
+}
+
+////////////////////////////////////////////////////////////////////////////////
// NativeTabbedPaneGtk, private:
void NativeTabbedPaneGtk::DoAddTabAtIndex(int index, const std::wstring& title,
View* contents,
@@ -159,11 +166,17 @@ void NativeTabbedPaneGtk::DoAddTabAtIndex(int index, const std::wstring& title,
gtk_notebook_set_current_page(GTK_NOTEBOOK(native_view()), 0);
}
-View* NativeTabbedPaneGtk::GetTabViewAt(int index) {
+WidgetGtk* NativeTabbedPaneGtk::GetWidgetAt(int index) {
DCHECK(index <= GetTabCount());
GtkWidget* page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(native_view()),
index);
WidgetGtk* widget = WidgetGtk::GetViewForNative(page);
+ DCHECK(widget);
+ return widget;
+}
+
+View* NativeTabbedPaneGtk::GetTabViewAt(int index) {
+ WidgetGtk* widget = GetWidgetAt(index);
DCHECK(widget && widget->GetRootView()->GetChildViewCount() == 1);
return widget->GetRootView()->GetChildViewAt(0);
}
diff --git a/views/controls/tabbed_pane/native_tabbed_pane_gtk.h b/views/controls/tabbed_pane/native_tabbed_pane_gtk.h
index 63a70f7..d586e74 100644
--- a/views/controls/tabbed_pane/native_tabbed_pane_gtk.h
+++ b/views/controls/tabbed_pane/native_tabbed_pane_gtk.h
@@ -36,11 +36,18 @@ class NativeTabbedPaneGtk : public NativeControlGtk,
// NativeControlGtk overrides.
virtual void CreateNativeControl();
+ // View override:
+ virtual FocusTraversable* GetFocusTraversable();
+
private:
void DoAddTabAtIndex(int index,
const std::wstring& title,
View* contents,
bool select_if_first_tab);
+
+ // Returns the WidgetGtk containing the tab contents at |index|.
+ WidgetGtk* GetWidgetAt(int index);
+
View* GetTabViewAt(int index);
void OnSwitchPage(int selected_tab_index);