summaryrefslogtreecommitdiffstats
path: root/views/controls
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-29 17:40:13 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-29 17:40:13 +0000
commitcec6c9c550f44741c7acacfd5d3f67e919110c4c (patch)
treef6778f4a10b1aa5b0a7b74526c632377214703b1 /views/controls
parent210796e7c8207e56dae29392b62e1e79ec9f837f (diff)
downloadchromium_src-cec6c9c550f44741c7acacfd5d3f67e919110c4c.zip
chromium_src-cec6c9c550f44741c7acacfd5d3f67e919110c4c.tar.gz
chromium_src-cec6c9c550f44741c7acacfd5d3f67e919110c4c.tar.bz2
See original review at
http://codereview.chromium.org/251001/show This CL hooks the focus traversal for the TabbedPaneView on Linux with toolkit views. It also has few focus related fixed (focus with buttons, clearing focus effectively in the focus manager). BUG=None TEST=Run the view_examples app. Press tab to move the focus. Try the different tabs. Review URL: http://codereview.chromium.org/246030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27504 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls')
-rw-r--r--views/controls/button/button.cc1
-rw-r--r--views/controls/button/native_button.cc2
-rw-r--r--views/controls/button/text_button.cc1
-rw-r--r--views/controls/tabbed_pane/native_tabbed_pane_gtk.cc15
-rw-r--r--views/controls/tabbed_pane/native_tabbed_pane_gtk.h7
5 files changed, 23 insertions, 3 deletions
diff --git a/views/controls/button/button.cc b/views/controls/button/button.cc
index 504a2f5..460c424 100644
--- a/views/controls/button/button.cc
+++ b/views/controls/button/button.cc
@@ -64,6 +64,7 @@ Button::Button(ButtonListener* listener)
: listener_(listener),
tag_(-1),
mouse_event_flags_(0) {
+ SetFocusable(true);
}
void Button::NotifyClick(const views::Event& event) {
diff --git a/views/controls/button/native_button.cc b/views/controls/button/native_button.cc
index 811fb56..76fb0ff 100644
--- a/views/controls/button/native_button.cc
+++ b/views/controls/button/native_button.cc
@@ -36,7 +36,6 @@ NativeButton::NativeButton(ButtonListener* listener)
is_default_(false),
ignore_minimum_size_(false) {
InitBorder();
- SetFocusable(true);
}
NativeButton::NativeButton(ButtonListener* listener, const std::wstring& label)
@@ -46,7 +45,6 @@ NativeButton::NativeButton(ButtonListener* listener, const std::wstring& label)
ignore_minimum_size_(false) {
SetLabel(label); // SetLabel takes care of label layout in RTL UI.
InitBorder();
- SetFocusable(true);
}
NativeButton::~NativeButton() {
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/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);